Search in sources :

Example 1 with ListIdentifier

use of com.revolsys.identifier.ListIdentifier in project com.revolsys.open by revolsys.

the class Record method getIdentifier.

@Override
default Identifier getIdentifier() {
    final RecordDefinition recordDefinition = getRecordDefinition();
    final List<Integer> idFieldIndexes = recordDefinition.getIdFieldIndexes();
    final int idCount = idFieldIndexes.size();
    if (idCount == 0) {
        return null;
    } else if (idCount == 1) {
        final Integer idFieldIndex = idFieldIndexes.get(0);
        final Object idValue = getValue(idFieldIndex);
        if (idValue == null) {
            return null;
        } else {
            return Identifier.newIdentifier(idValue);
        }
    } else {
        boolean notNull = false;
        final Object[] idValues = new Object[idCount];
        for (int i = 0; i < idValues.length; i++) {
            final Integer idFieldIndex = idFieldIndexes.get(i);
            final Object value = getValue(idFieldIndex);
            if (value != null) {
                notNull = true;
            }
            idValues[i] = value;
        }
        if (notNull) {
            return new ListIdentifier(idValues);
        } else {
            return null;
        }
    }
}
Also used : ListIdentifier(com.revolsys.identifier.ListIdentifier) RecordDefinition(com.revolsys.record.schema.RecordDefinition)

Aggregations

ListIdentifier (com.revolsys.identifier.ListIdentifier)1 RecordDefinition (com.revolsys.record.schema.RecordDefinition)1