public static <T> Key<T> get(Class<T> cls) { return new Key<T>(TypeToken.of(cls), null); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Attribute<?> other = (Attribute<?>) obj; if (key == null) { if (other.key != null) return false; } else if (!key.equals(other.key)) return false; if (value == null) { if (other.value != null) return false; } else if (!value.equals(other.value)) return false; return true; } }
public static Key<String> keyOf(String key) { return Key.get(String.class, Names.named(key)); }
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 <T> void add(Class<T> cls, T value) { add(new Attribute<T>(Key.get(cls), value)); }
public <T> T getAttribute(TypeToken<T> type, Annotation annotation) { return getAttribute(Key.get(type, annotation)); }
public <T> void addAttribute(TypeToken<T> key, T val) { addAttribute(Key.get(key), val); }
public <T> void addAttribute(Class<T> key, T val) { addAttribute(Key.get(key), val); }
public <T> T getAttribute(TypeToken<T> type) { return getAttribute(Key.get(type)); }
public <T> T getAttribute(Class<T> cls, Annotation annotation) { return getAttribute(Key.get(cls, annotation)); }
public <T> void addAttribute(Class<T> key, String annotation, T val) { addAttribute(Key.get(key, Names.named(annotation)), val); }
public <T> void addAttribute(TypeToken<T> key, Annotation annotation, T val) { addAttribute(Key.get(key, annotation), val); }
public static <T> Key<T> get(TypeToken<T> type, Annotation annotation) { return new Key<T>(type, annotation); }
public <T> T typeSafeGet(Class<T> cls) { return typeSafeGet(Key.get(cls)); }
public <T> T getAttribute(Class<T> cls, String annotation) { return getAttribute(Key.get(cls, Names.named(annotation))); }
public <T> void addAttribute(Class<T> key, Annotation annotation, T val) { addAttribute(Key.get(key, annotation), val); }
public <T> void addAttribute(TypeToken<T> key, String annotation, T val) { addAttribute(Key.get(key, Names.named(annotation)), val); }
public <T> void add(Class<T> cls, String string, T value) { add(new Attribute<T>(Key.get(cls, Names.named(string)), value)); }
public <T> T getAttribute(TypeToken<T> type, String annotation) { return getAttribute(Key.get(type, Names.named(annotation))); }
public <T> T getAttribute(Class<T> cls) { return getAttribute(Key.get(cls)); }