@Override public File unwrapMetaValue(MetaValue metaValue) { SimpleValue svalue = (SimpleValue) metaValue; File f = null; if (svalue != null) { f = new File(svalue.getValue().toString()); } return f; } }
@Override public boolean isValue(Object obj) { if (obj == null || obj instanceof SimpleValue == false) return false; SimpleValue value = (SimpleValue) obj; if (SimpleMetaType.STRING == value.getMetaType() == false) return false; return validValues.contains(value.getValue()); }
@Override public boolean isValue(Object obj) { if (obj == null || obj instanceof SimpleValue == false) return false; SimpleValue value = (SimpleValue) obj; return equals(value.getMetaType()); }
@Override public boolean isValue(Object obj) { if (obj == null || obj instanceof SimpleValue == false) return false; SimpleValue value = (SimpleValue) obj; return equals(value.getMetaType()); }
@Override public File unwrapMetaValue(MetaValue metaValue) { SimpleValue svalue = (SimpleValue) metaValue; File f = null; if(svalue != null) { f = new File(svalue.getValue().toString()); } return f; } }
public int compare(SimpleValue o1, SimpleValue o2) { SimpleMetaType smt1 = o1.getMetaType(); SimpleMetaType smt2 = o2.getMetaType(); return (smt1 == smt2) ? smt1.compare(o1.getValue(), o2.getValue()) : -1; } }
@Override public File unwrapMetaValue(MetaValue metaValue) { SimpleValue svalue = (SimpleValue) metaValue; File f = null; if (svalue != null) { f = new File(svalue.getValue().toString()); } return f; } }
@Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof SimpleValue == false) return false; SimpleValue other = (SimpleValue) obj; if (metaType.equals(other.getMetaType()) == false) return false; Object otherValue = other.getValue(); if (value == null && otherValue == null) return true; if (value == null && otherValue != null) return false; return value.equals(otherValue); }
@Override public ObjectName unwrapMetaValue(MetaValue metaValue) { SimpleValue sv = (SimpleValue) metaValue; String str = sv.getValue().toString(); try { return new ObjectName(str); } catch(Exception e) { throw new IllegalArgumentException(e); } }
@Override public boolean equals(Object obj) { if (obj == this) return true; if (obj == null || obj instanceof SimpleValue == false) return false; SimpleValue other = (SimpleValue) obj; if (metaType.equals(other.getMetaType()) == false) { // Check equivalent types if (metaType.equalsIgnorePrimitive(other.getMetaType()) == false) return false; } Object otherValue = other.getValue(); if (value == null && otherValue == null) return true; if (value == null && otherValue != null) return false; return value.equals(otherValue); }
@Override public ProfileKey unwrapMetaValue(MetaValue metaValue) { if(metaValue != null && SimpleMetaType.STRING.equals(metaValue.getMetaType())) { String profileName = String.class.cast(((SimpleValue) metaValue).getValue()); return new ProfileKey(profileName); } throw new IllegalStateException("cannot recreate profile key"); }
/** * Validate that obj is a SimpleValue.STRING or EnumValue whose string * value is in the set of valid enum strings. * @return true if obj is a valid enum string for this type. */ @Override public boolean isValue(Object obj) { if (obj == null || (obj instanceof SimpleValue == false && obj instanceof EnumValue == false)) return false; String enumString = null; if(obj instanceof SimpleValue) { SimpleValue value = SimpleValue.class.cast(obj); if (SimpleMetaType.STRING == value.getMetaType() == false) return false; enumString = value.getValue().toString(); } else { EnumValue value = EnumValue.class.cast(obj); enumString = value.getValue(); } return validValues.contains(enumString); }
/** * Get ref name. * * @param value property value * @return plain value */ protected Object getRefName(Object value) { if (value instanceof MetaValue) { MetaValue metaValue = MetaValue.class.cast(value); if (metaValue.getMetaType().isSimple() == false) { throw new IllegalArgumentException("Can only get ref from simple value: " + value); } return SimpleValue.class.cast(metaValue).getValue(); } return value; }
if(getMetaType() == SimpleMetaType.BIGINTEGER && sv.getMetaType() == SimpleMetaType.BIGINTEGER) BigInteger v2 = BigInteger.class.cast(sv.getValue()); compare = v1.compareTo(v2); else if(getMetaType() == SimpleMetaType.BIGDECIMAL && sv.getMetaType() == SimpleMetaType.BIGDECIMAL) BigDecimal v2 = BigDecimal.class.cast(sv.getValue()); compare = v1.compareTo(v2); else if(getMetaType() == SimpleMetaType.BOOLEAN && sv.getMetaType() == SimpleMetaType.BOOLEAN) Boolean v2 = Boolean.class.cast(sv.getValue()); compare = v1.compareTo(v2); else if(getMetaType() == SimpleMetaType.BOOLEAN_PRIMITIVE && sv.getMetaType() == SimpleMetaType.BOOLEAN_PRIMITIVE) Boolean v2 = Boolean.class.cast(sv.getValue()); compare = v1.compareTo(v2); else if(getMetaType() == SimpleMetaType.BYTE && sv.getMetaType() == SimpleMetaType.BYTE) Byte v2 = Byte.class.cast(sv.getValue()); compare = v1.compareTo(v2); else if(getMetaType() == SimpleMetaType.CHARACTER && sv.getMetaType() == SimpleMetaType.CHARACTER) Character v2 = Character.class.cast(sv.getValue()); compare = v1.compareTo(v2);
@Override public ProfileKey unwrapMetaValue(MetaValue metaValue) { if(metaValue != null && SimpleMetaType.STRING.equals(metaValue.getMetaType())) { String profileName = String.class.cast(((SimpleValue) metaValue).getValue()); return new ProfileKey(profileName); } throw new IllegalStateException("cannot recreate profile key"); }
@Override public ObjectName unwrapMetaValue(MetaValue metaValue) { CompositeValue compositeValue = (CompositeValue) metaValue; SimpleValue domain = (SimpleValue) compositeValue.get("domain"); String domainUnwrap = (String) domain.getValue(); MetaValue keys = compositeValue.get("keyPropertyList"); Hashtable keysUnwrap = null; if(keys instanceof PropertiesMetaValue) keysUnwrap = (PropertiesMetaValue) keys; try { ObjectName name = new ObjectName(domainUnwrap, keysUnwrap); return name; } catch(Exception e) { throw new IllegalArgumentException(e); } }
public Version unwrapMetaValue(MetaValue metaValue) { if (SimpleMetaType.STRING.equals(metaValue.getMetaType()) == false) throw new IllegalArgumentException("Not a string: " + metaValue); SimpleValue simple = (SimpleValue) metaValue; String value = (String) simple.getValue(); return Version.parseVersion(value); } }
@Override public ObjectName unwrapMetaValue(MetaValue metaValue) { CompositeValue cv = (CompositeValue) metaValue; String domain = null; Hashtable<String, String> props = new Hashtable<String, String>(); for(String key : cv.getMetaType().itemSet()) { SimpleValue svalue = (SimpleValue) cv.get(key); String value = (String) svalue.getValue(); if(key.equalsIgnoreCase("domain")) domain = value; else props.put(key, value); } try { ObjectName name = new ObjectName(domain, props); return name; } catch(Exception e) { throw new IllegalArgumentException("Failed to build ObjectName from MetaValue: "+metaValue, e); } }
String protName = (String) ((SimpleValue) protocolValue.get("name")).getValue(); String protClass = (String) ((SimpleValue) protocolValue.get("className")).getValue(); CompositeValue paramsValue = (CompositeValue) protocolValue.get("protocolParameters"); Set<String> paramNames = paramsValue.getMetaType().keySet(); String paramVal = (String) ((SimpleValue) paramValue.get("value")).getValue(); protParams.add(new ProtocolParameter(paramName, paramVal));