/** * Retrieves the attribute by key from the list of attributes */ public <T> T getAttr(Key<T> key) { final Attribute<T> value = (Attribute<T>) get(key); if (value == null) return null; return value.getValue(); }
public <T> T typeSafeGet(Key<T> key) { Attribute<?> attr = get(key); if (attr == null) return null; return (T) attr.getValue(); }
@Override public String toString() { return " " + this.getKey() + "(" + this.getValue() + ")"; }
/** * Retrieves the attribute by key from the list of attributes * * @param key * @return a value for key in the list of attributes or the default value. */ public <T> T getAttribute(Key<T> key) { if (attributes == null) return null; final Attribute<T> value = (Attribute<T>) attributes.get(key); if (value == null) return null; return value.getValue(); }
public static org.kframework.attributes.Att convertAttributes(ASTNode t) { Attributes attributes = t.getAttributes(); Map<String, String> attributesSet = attributes .keySet() .stream() .map(key -> { String keyString = key.toString(); String valueString = attributes.get(key).getValue().toString(); if (keyString.equals("klabel")) { return Tuple2.apply("klabel", valueString); } else { return Tuple2.apply(keyString, valueString); } }).collect(Collectors.toMap(Tuple2::_1, Tuple2::_2)); return Att().addAll(attributesSet) .addAll(attributesFromLocation(t.getLocation())) .addAll(attributesFromSource(t.getSource())); }