Skip to content
Snippets Groups Projects
Commit 586ae778 authored by Jonas Blatt's avatar Jonas Blatt :ant:
Browse files

Add documentation for VTypeRef

parent ac8f83cc
No related branches found
No related tags found
No related merge requests found
......@@ -10,27 +10,49 @@ import de.unikoblenz.fgbks.base.utils.boundary.impl.LongBoundary;
import de.unikoblenz.fgbks.base.utils.boundary.impl.StringBoundary;
import java.time.LocalDateTime;
import java.util.Optional;
import org.camunda.bpm.model.dmn.instance.TypeRef;
/**
* Enum for mapping camunda data types {@link TypeRef} to {@link Boundary} classes.
*/
public enum VTypeRef {
/**
* Date format, which is represented as {@link DateBoundary} and as java type {@link
* LocalDateTime}.
*/
DATE("date", LocalDateTime.class, DateBoundary.class),
/**
* String format, which is represented as {@link StringBoundary} and as java type {@link String}.
*/
STRING("string", String.class, StringBoundary.class),
/**
* Integer format, which is represented as {@link IntegerBoundary} and as java type {@link
* Integer}.
*/
INTEGER("integer", Integer.class, IntegerBoundary.class),
/**
* Boolean format, which is represented as {@link BooleanBoundary} and as java type {@link
* Boolean}.
*/
BOOLEAN("boolean", Boolean.class, BooleanBoundary.class),
/**
* Double format, which is represented as {@link DoubleBoundary} and as java type {@link Double}.
*/
DOUBLE("double", Double.class, DoubleBoundary.class),
/** Long format, which is represented as {@link LongBoundary} and as java type {@link Long}. */
LONG("long", Long.class, LongBoundary.class);
private String name;
private Class<?> javaClass;
private Class<? extends Boundary> boundaryClass;
public String getName() {
return name;
}
public Class<?> getJavaClass() {
return javaClass;
}
/**
* Get the {@link VTypeRef} with the given name or {@link null}, if no VTypeRef was found with the
* given name.
*
* @param name the name as String
* @return the {@link VTypeRef} with the given name
*/
public static VTypeRef getTypeRefFromName(String name) {
for (VTypeRef typeRef : values()) {
if (typeRef.name.equals(name)) {
......@@ -40,6 +62,13 @@ public enum VTypeRef {
return null;
}
/**
* Get the {@link VTypeRef} with the given java {@link Class} or {@link null}, if no VTypeRef was
* found with the given java {@link Class}.
*
* @param javaClass java {@link Class}
* @return the {@link VTypeRef} with the given java {@link Class}
*/
public static VTypeRef getTypeRefFromJavaClass(Class<?> javaClass) {
for (VTypeRef typeRef : values()) {
if (typeRef.javaClass.equals(javaClass)) {
......@@ -49,6 +78,31 @@ public enum VTypeRef {
return null;
}
/**
* Get the name of the type.
*
* @return the name as {@link String}.
*/
public String getName() {
return name;
}
/**
* Get the corresponding java class.
*
* @return the java {@link Class}.
*/
public Class<?> getJavaClass() {
return javaClass;
}
/**
* Get a new {@link Boundary} instance with text as input. If the input text can not be parsed,
* the result is a {@link InvalidBoundary}.
*
* @param text the String to parse the new {@link Boundary}
* @return a Optional of a new {@link Boundary}
*/
public Optional<Boundary> getBoundaryFromText(String text) {
try {
return Optional.of(boundaryClass.getDeclaredConstructor(String.class).newInstance(text));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment