com.jaxio.celerio.model.support.AttributePredicates Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of celerio-engine Show documentation
Show all versions of celerio-engine Show documentation
Celerio Core Generation Engine
/*
* Copyright 2015 JAXIO http://www.jaxio.com
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.jaxio.celerio.model.support;
import com.google.common.base.Predicate;
import com.jaxio.celerio.model.Attribute;
import static com.google.common.base.Predicates.not;
import static com.google.common.base.Predicates.or;
public class AttributePredicates {
public static Predicate LOCALE_KEY = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.isLocaleKey();
}
};
public static Predicate LOCALIZABLE = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.isLocalizable();
}
};
public static Predicate FILE = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.isFile();
}
};
public static Predicate SIMPLE = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.isSimple();
}
};
public static Predicate VISIBLE = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.isVisible();
}
};
public static Predicate HIDDEN = not(VISIBLE);
public static Predicate SORTABLE = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.isSortable();
}
};
public static Predicate FORM_FIELD = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.isFormField();
}
};
public static Predicate SEARCH_FIELD = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.isSearchField();
}
};
public static Predicate RANGEABLE_FIELD = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.isRangeable();
}
};
/**
* Fields that can be used with the PropertySelector.
*/
public static Predicate MULTI_SELECTABLE_FIELD = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.isMultiSelectable();
}
};
public static Predicate SEARCH_RESULT_CONVENTION = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.isSearchResultFieldConvention();
}
};
public static Predicate SEARCH_RESULT_FIELD_DEFINED_MANUALLY = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
if (attribute.getColumnConfig().getSearchResult() != null) {
return attribute.getColumnConfig().getSearchResult();
}
return false;
}
};
public static Predicate HIBERNATE_SEARCH_FIELD = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.getColumnConfig().getIndexedField() != null;
}
};
public static Predicate SIMPLE_PK = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.isSimplePk();
}
};
public static Predicate IS_UNIQUE = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.isUnique();
}
};
public static Predicate IN_COMPOSITE_PK = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.isInCpk();
}
};
public static Predicate IN_PK = or(SIMPLE_PK, IN_COMPOSITE_PK);
public static Predicate NOT_IN_PK = not(IN_PK);
public static Predicate NOT_IN_COMPOSITE_PK = not(IN_COMPOSITE_PK);
public static Predicate NOT_SIMPLE_PK = not(SIMPLE_PK);
public static Predicate SIMPLE_FK = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.isSimpleFk();
}
};
public static Predicate IN_COMPOSITE_FK = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.isInCompositeFk();
}
};
public static Predicate IN_FK = or(SIMPLE_FK, IN_COMPOSITE_FK);
public static Predicate NOT_IN_FK = not(IN_FK);
public static Predicate BUSINESS_KEY_BY_CONFIGURATION = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.getColumnConfig().hasTrueBusinessKey();
}
};
public static Predicate ENUM = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.isEnum();
}
};
public static Predicate HAS_PERTINENT_DEFAULT_VALUE = new Predicate() {
@Override
public boolean apply(Attribute attribute) {
return attribute.hasPertinentDefaultValue();
}
};
public static Predicate NUMERIC = new Predicate() {
@Override
public boolean apply(Attribute input) {
return input.isNumeric();
}
};
public static Predicate DATE = new Predicate() {
@Override
public boolean apply(Attribute input) {
return input.isDate();
}
};
public static Predicate DEFAULT_SORT = new Predicate() {
@Override
public boolean apply(Attribute input) {
return input.isSimple() && input.isInBk();
// TODO: default sort by configuration
}
};
public static Predicate BIG_INTEGER = new Predicate() {
@Override
public boolean apply(Attribute input) {
return input.isBigInteger();
}
};
public static Predicate VERSION = new Predicate() {
@Override
public boolean apply(Attribute input) {
return input.isVersion();
}
};
public static Predicate NOT_VERSION = not(VERSION);
public static Predicate STRING = new Predicate() {
@Override
public boolean apply(Attribute input) {
return input.isString();
}
};
public static Predicate BOOLEAN = new Predicate() {
@Override
public boolean apply(Attribute input) {
return input.isBoolean();
}
};
public static Predicate BLOB = new Predicate() {
@Override
public boolean apply(Attribute input) {
return input.isBlob();
}
};
public static Predicate IS_PATTERN_SEARCHABLE = new Predicate() {
@Override
public boolean apply(Attribute input) {
return input.isPatternSearchable();
}
};
public static Predicate IS_CPK_PATTERN_SEARCHABLE = new Predicate() {
@Override
public boolean apply(Attribute input) {
return input.isCpkPatternSearchable();
}
};
public static Predicate WITH_PUBLIC_SETTER_ACCESSIBILITY = new Predicate() {
@Override
public boolean apply(Attribute input) {
return input.isSetterAccessibilityPublic();
}
};
public static Predicate IS_DATE = new Predicate() {
@Override
public boolean apply(Attribute input) {
return input.isDate();
}
};
public static Predicate IS_STRING = new Predicate() {
@Override
public boolean apply(Attribute input) {
return input.isString();
}
};
public static Predicate IS_LABEL = new Predicate() {
@Override
public boolean apply(Attribute input) {
return input.isLabel();
}
};
}