All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
de.knightsoftnet.gwtp.spring.annotation.processor.BackofficeWidget Maven / Gradle / Ivy
package de.knightsoftnet.gwtp.spring.annotation.processor;
import de.knightsoftnet.validators.shared.data.FieldTypeEnum;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;
import javax.lang.model.element.Element;
import javax.lang.model.type.DeclaredType;
/**
* Widget data used for generating ui binder and view.
*/
public class BackofficeWidget {
private DeclaredType containing;
private Element field;
private String name;
private List imports;
private String widgetName;
private List parameters;
private boolean provided;
private String providedConstruction;
private FieldTypeEnum fieldType;
private List childWidgets;
/**
* Default constructor.
*/
public BackofficeWidget() {
super();
childWidgets = new ArrayList<>();
}
/**
* Constructor initializing fields.
*
* @param containing the declared type containing the element
* @param field the field element
* @param name field name
* @param imports list of required imports
* @param widgetName widget name
* @param parameters list of parameters
* @param provided create widget as provided
* @param providedConstruction construction used when provided
* @param fieldType type of the field, important for search implementation
* @param childWidgets list of widgets which are child of this widget
*/
public BackofficeWidget(final DeclaredType containing, final Element field, final String name,
final List imports, final String widgetName,
final List parameters, final boolean provided,
final String providedConstruction, final FieldTypeEnum fieldType,
final List childWidgets) {
super();
this.containing = containing;
this.field = field;
this.name = name;
this.imports = imports;
this.widgetName = widgetName;
this.parameters = parameters;
this.provided = provided;
this.providedConstruction = providedConstruction;
this.fieldType = fieldType;
this.childWidgets = childWidgets;
}
public static BackofficeWidget of(final DeclaredType containing, final Element field,
final String name, final List imports, final String widgetName,
final List parameters, final boolean provided,
final String providedConstruction, final FieldTypeEnum fieldType,
final List childWidgets) {
return new BackofficeWidget(containing, field, name, imports, widgetName, parameters, provided,
providedConstruction, fieldType, childWidgets);
}
public DeclaredType getContaining() {
return containing;
}
public void setContaining(final DeclaredType containing) {
this.containing = containing;
}
public Element getField() {
return field;
}
public void setField(final Element field) {
this.field = field;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name;
}
public List getImports() {
return imports;
}
public void setImports(final List imports) {
this.imports = imports;
}
public String getWidgetName() {
return widgetName;
}
public void setWidgetName(final String widgetName) {
this.widgetName = widgetName;
}
public List getParameters() {
return parameters;
}
public void setParameters(final List parameters) {
this.parameters = parameters;
}
public boolean isProvided() {
return provided;
}
public void setProvided(final boolean provided) {
this.provided = provided;
}
public String getProvidedConstruction() {
return providedConstruction;
}
public void setProvidedConstruction(final String providedConstruction) {
this.providedConstruction = providedConstruction;
}
public FieldTypeEnum getFieldType() {
return fieldType;
}
public void setFieldType(final FieldTypeEnum fieldType) {
this.fieldType = fieldType;
}
public List getChildWidgets() {
return childWidgets;
}
public void setChildWidgets(final List childWidgets) {
this.childWidgets = childWidgets;
}
public Stream streamFlatBackofficeWidget() {
return streamFlatBackofficeWidget(null);
}
/**
* flat backoffice widgets and concatenate names.
*
* @param parent widget name of parent widget
* @return flat backoffice widget stream
*/
public Stream streamFlatBackofficeWidget(final String parent) {
final String prefix = StringUtils.isEmpty(parent) ? StringUtils.EMPTY : parent + ".";
return Stream.concat(
Stream.of(of(getContaining(), getField(), prefix + getName(), getImports(), getWidgetName(),
getParameters(), isProvided(), getProvidedConstruction(), getFieldType(),
getChildWidgets())),
childWidgets.stream()
.flatMap(entry -> entry.streamFlatBackofficeWidget(prefix + getName())));
}
@Override
public int hashCode() {
return Objects.hash(name);
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final BackofficeWidget other = (BackofficeWidget) obj;
return Objects.equals(name, other.name);
}
@Override
public String toString() {
return "BackofficeWidget [name=" + name + ", imports=" + imports + ", widgetName=" + widgetName
+ ", parameters=" + parameters + ", provided=" + provided + ", providedConstruction="
+ providedConstruction + ", fieldType=" + fieldType + ", childWidgets=" + childWidgets
+ "]";
}
}