All Downloads are FREE. Search and download functionalities are using the official Maven repository.

in.kuros.jfirebase.provider.firebase.EntityHelper Maven / Gradle / Ivy

package in.kuros.jfirebase.provider.firebase;

import in.kuros.jfirebase.entity.Entity;
import in.kuros.jfirebase.entity.EntityDeclarationException;
import in.kuros.jfirebase.metadata.AttributeValue;

import java.util.List;
import java.util.Optional;
import java.util.Set;

public interface EntityHelper {

     String getDocumentPath(T entity);

     String getDocumentPath(List> attributeValues);

     String getCollectionPath(T entity);

     String getCollectionPath(List> attributeValues);

     void setId(T entity, String id);

     String getId(T entity);

     void setCreateTime(T entity);

     boolean setUpdateTime(T entity);

    Optional getUpdateTimeFieldName(Class type);

     Set getAllRequiredIdFields(Class type);

     void validateIdsNotNull(T object);

    static String getMappedCollection(final Class aClass) {
        return getEntity(aClass).value();
    }

    static Entity getEntity(final Class aClass) {
        final Entity annotation = aClass.getAnnotation(Entity.class);
        if (annotation == null) {
            throw new EntityDeclarationException("No annotation found for Entity: " + aClass);
        }
        return annotation;
    }

    EntityHelper INSTANCE = new EntityHelperImpl();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy