protected void setParameterBase(ParameterBase parameterBase) { this.parameterBase = parameterBase; String codeName = parameterBase.getCodeName(); if (codeName == null) codeName = ""; this.simpleName = String.format( "%s/%s/%s", parameterBase.getComponentName(), codeName, parameterBase.getParameterName()); }
/** * creates a String to be included in a .preperties file * * @param value default value to be included in the text * @return */ public String toPropertyString(String value, boolean commentOutValue) { if (value == null) { value = ""; } StringBuilder builder = new StringBuilder(); String pathName = parameterBase.getPath().toString(); builder.append("\n#******** ").append(pathName); if (description != null) { String withPounds = description.replaceAll("\n", "\n#"); builder.append('\n').append("#** ").append(withPounds); } if (isNotModifiableAtRuntime()) { builder.append("\n#** static parameter (not modifiable at runtime)"); } if (constraints != null && !"".equals(constraints.trim())) { builder .append("\n#** constraints : ") .append(constraints) .append(" ; type : ") .append(TypeInfos.get(parameterBase.getTypeName())); } else { builder.append("\n#** type : ").append(TypeInfos.get(parameterBase.getTypeName())); } if (category != null && !"".equals(category.trim())) { builder.append("\n#** category : ").append(category); } String propName = this.simpleName; if (propName == null || "".equals(propName.trim())) { propName = pathName; } else { propName = propName.trim().replaceAll(" ", "\\\\ "); } builder .append("\n#**\n#********\n\n") .append(commentOutValue ? "#" : "") .append(propName) .append(" = ") .append(value) .append('\n'); // System.out.println(" -> -> " +builder ); return builder.toString(); }
/** * equals is special: it works with any Path Object! * * @param o * @return */ @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof PathObject)) return false; PathObject that = (PathObject) o; if (!parameterBase.getPath().equals(that.getPath())) return false; return true; }
public String getTypeName() { return parameterBase.getTypeName(); }
@Override public ParameterPath getPath() { return parameterBase.getPath(); }
public String getDefaultValue() { return parameterBase.getDefaultValue(); }
public String getParameterName() { return parameterBase.getParameterName(); }
public String getComponentName() { return parameterBase.getComponentName(); }
@Override public int hashCode() { return parameterBase.getPath().hashCode(); }