/** * Appends an attribute to the list of attributes. * * @param key * @param val */ public void addAttribute(String key, String val) { addAttribute(Attribute.of(key, val)); }
/** * 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(); }
/** * 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 String getAttribute(String key) { return getAttribute(Attribute.keyOf(key)); }
@Override public Attribute<T> shallowCopy() { return new Attribute<T>(this); }
public void add(Attribute<?> e) { contents.put(e.getKey(), e); }
public <T> T typeSafeGet(Key<T> key) { Attribute<?> attr = get(key); if (attr == null) return null; return (T) attr.getValue(); }
/** * @param key * @return whether the attribute key occurs in the list of attributes. */ public boolean containsAttribute(String key) { if (attributes == null) return false; return attributes.containsKey(Attribute.keyOf(key)); }
public <T> void addAttribute(Key<T> key, T val) { addAttribute(new Attribute<>(key, val)); }
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); contents = new LinkedHashMap<>(); Set<Attribute<?>> attributes = (Set<Attribute<?>>) stream.readObject(); for (Attribute<?> attr : attributes) { contents.put(attr.getKey(), attr); } } }
/** * 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 String getAttr(String key) { return getAttr(Attribute.keyOf(key)); }
public <T> void add(Class<T> cls, String string, T value) { add(new Attribute<T>(Key.get(cls, Names.named(string)), value)); }
public void addProduction(Production p, boolean kore) { if (p.getKLabel(false) != null) { tags.put(p.getKLabel(false), p); } for (Attribute<?> a : p.getAttributes().values()) { tags.put(a.getKey().toString(), p); } } }
node.addAttribute(markLoc(loc, Attribute.of(key, val)));
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())); }
public void removeAttribute(String key) { getAttributes().remove(Attribute.keyOf(key)); }
public <T> void add(Class<T> cls, T value) { add(new Attribute<T>(Key.get(cls), value)); }