diff options
Diffstat (limited to 'src/main/java/nu/xss/jpa/query/filter/EntityFilter.java')
-rw-r--r-- | src/main/java/nu/xss/jpa/query/filter/EntityFilter.java | 62 |
1 files changed, 58 insertions, 4 deletions
diff --git a/src/main/java/nu/xss/jpa/query/filter/EntityFilter.java b/src/main/java/nu/xss/jpa/query/filter/EntityFilter.java index 6af0a0b..357f7b1 100644 --- a/src/main/java/nu/xss/jpa/query/filter/EntityFilter.java +++ b/src/main/java/nu/xss/jpa/query/filter/EntityFilter.java @@ -1,3 +1,23 @@ +/** + * This file is part of xss-jpa. + * + * Copyright 2012 Sebastian Schmelzer + * http://xss.nu/ + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with library. If not, see <http://www.gnu.org/licenses/>. + * + */ package nu.xss.jpa.query.filter; import java.lang.reflect.Field; @@ -9,13 +29,29 @@ import java.util.List; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.Root; +/** + * The Class EntityFilter. + * + * @param <E> + * the element type + */ public class EntityFilter<E> extends AbstractFilter<E> { + /** The entity. */ private Class<E> entity; + /** The flags. */ private List<EntityFilterFlags> flags = new ArrayList<EntityFilterFlags>(); - public EntityFilter(Class<E> entity, EntityFilterFlags... flags) { + /** + * Instantiates a new entity filter. + * + * @param entity + * the entity + * @param flags + * the flags + */ + public EntityFilter(final Class<E> entity, final EntityFilterFlags... flags) { super(); this.setEntity(entity); for (EntityFilterFlags f : flags) { @@ -24,7 +60,7 @@ public class EntityFilter<E> extends AbstractFilter<E> { } @Override - public void buildFilters(CriteriaBuilder cb, Root<?> from) { + public void buildFilters(final CriteriaBuilder cb, final Root<?> from) { List<Field> fields = getInheritedFields(entity); List<Method> methods = new ArrayList<Method>(); System.out.println(fields.toString()); @@ -36,15 +72,33 @@ public class EntityFilter<E> extends AbstractFilter<E> { System.out.println(methods.toString()); } + /** + * Gets the entity. + * + * @return the entity + */ public Class<E> getEntity() { return entity; } - public void setEntity(Class<E> entity) { + /** + * Sets the entity. + * + * @param entity + * the new entity + */ + public void setEntity(final Class<E> entity) { this.entity = entity; } - private List<Field> getInheritedFields(Class<?> type) { + /** + * Gets the inherited fields. + * + * @param type + * the type + * @return the inherited fields + */ + private List<Field> getInheritedFields(final Class<?> type) { List<Field> fields = new ArrayList<Field>(); for (Class<?> c = type; c != null; c = c.getSuperclass()) { fields.addAll(Arrays.asList(c.getDeclaredFields())); |