
com.couchbase.client.java.repository.mapping.ReflectionBasedEntityMetadata Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java-client Show documentation
Show all versions of java-client Show documentation
The official Couchbase Java SDK
package com.couchbase.client.java.repository.mapping;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
/**
* Reflection based implementation for entity metadata.
*
* @author Michael Nitschinger
* @since 2.2.0
*/
public class ReflectionBasedEntityMetadata implements EntityMetadata {
private final List properties;
private final PropertyMetadata idProperty;
public ReflectionBasedEntityMetadata(Class> sourceEntity) {
properties = new ArrayList();
PropertyMetadata idProperty = null;
for (Field field : sourceEntity.getDeclaredFields()) {
PropertyMetadata property = new ReflectionBasedPropertyMetadata(field);
properties.add(property);
if (property.isId()) {
idProperty = property;
}
}
this.idProperty = idProperty;
}
@Override
public List properties() {
return properties;
}
@Override
public boolean hasIdProperty() {
return idProperty != null;
}
@Override
public PropertyMetadata idProperty() {
return idProperty;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy