com.raynigon.unit_api.jackson.annotation.JsonUnitHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jackson-module Show documentation
Show all versions of jackson-module Show documentation
The jackson-module is a part of the unit-api
package com.raynigon.unit_api.jackson.annotation;
import com.raynigon.unit_api.core.annotation.QuantityShape;
/**
* Support a simple usage of the @JsonUnit properties
* */
public class JsonUnitHelper {
/**
* Determine the value of the shape property
* @param jsonUnit the annotation which should be processed
* @return the specified Shape or QuantityShape.NUMBER if no shape was specified
* */
public static QuantityShape getShape(JsonUnit jsonUnit){
if (jsonUnit == null) return QuantityShape.NUMBER;
return jsonUnit.shape();
}
/**
* Determine the value of the unit property
* @param jsonUnit the annotation which should be processed
* @return the name of the specified unit or null if no unit was specified
* */
public static String getUnitName(JsonUnit jsonUnit) {
if (jsonUnit == null) return null;
if (!jsonUnit.value().equals("")) return jsonUnit.value();
if (!jsonUnit.unit().equals("")) return jsonUnit.unit();
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy