OpenConcerto

Dépôt officiel du code source de l'ERP OpenConcerto
sonarqube

svn://code.openconcerto.org/openconcerto

Rev

Rev 151 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 151 Rev 156
Line 400... Line 400...
400
        cal.setTime(d);
400
        cal.setTime(d);
401
        return cal;
401
        return cal;
402
    }
402
    }
403
 
403
 
404
    public final <T> T getObjectAs(String field, Class<T> clazz) {
404
    public final <T> T getObjectAs(String field, Class<T> clazz) {
-
 
405
        return this.getObjectAs(field, false, clazz);
-
 
406
    }
-
 
407
 
-
 
408
    public final <T> T getObjectAs(final String field, final boolean mustBePresent, final Class<T> clazz) {
405
        T res = null;
409
        T res = null;
406
        try {
410
        try {
407
            res = clazz.cast(this.getObject(field));
411
            res = clazz.cast(this.getObject(field, mustBePresent));
408
        } catch (ClassCastException e) {
412
        } catch (ClassCastException e) {
409
            throw new IllegalArgumentException("Impossible d'accéder au champ " + field + " de la ligne " + this + " en tant que " + clazz.getSimpleName(), e);
413
            throw new IllegalArgumentException("Impossible d'accéder au champ " + field + " de la ligne " + this + " en tant que " + clazz.getSimpleName(), e);
410
        }
414
        }
411
        return res;
415
        return res;
412
    }
416
    }