コード例 #1
0
 public <T> List<T> getAll(AType<AttrList<T>> type) {
   AttrList<T> attrList = get(type);
   if (attrList == null) {
     return Collections.emptyList();
   }
   return attrList.getList();
 }
コード例 #2
0
 public <T> void add(AType<AttrList<T>> type, T obj) {
   AttrList<T> list = get(type);
   if (list == null) {
     list = new AttrList<T>(type);
     add(list);
   }
   list.getList().add(obj);
 }
コード例 #3
0
ファイル: RenamingTest.java プロジェクト: etcinitd/jalf
  @Test
  public void testProjectOnExtension() {
    Renaming r = Renaming.extension(sid, ssid, name, sname);
    Renaming expected = Renaming.extension(name, sname);

    // it works with a subset of original attributes
    AttrList list = AttrList.attrs(name);
    Renaming got = r.project(list);
    assertEquals(expected, got);

    // it is robust to a superset too (city was not part of it)
    list = AttrList.attrs(name, city);
    got = r.project(list);
    assertEquals(expected, got);
  }
コード例 #4
0
ファイル: Tuple.java プロジェクト: etcinitd/jalf
 /**
  * Returns a projection of this tuple on some of its attributes.
  *
  * <p>Note: despite its visibility, this method is part of JAlf protected API. It should not be
  * used by end users. TODO: how to fix this without hurting performance too much?
  *
  * @pre `on` must be a subset of this tuple's attributes.
  * @pre `resultingType` should be faithful to the actual result, that it it must guarantee the
  *     post condition.
  * @param on a list of attributes to project on.
  * @return a projection of this tuple on attributes specified in `on`.
  * @post `resultingType.contains(project(on, resultingType))` is true
  */
 public Tuple project(AttrList on, TupleType resultingType) {
   Map<AttrName, Object> p = new ConcurrentHashMap<>();
   on.forEach(attrName -> p.put(attrName, attrs.get(attrName)));
   return new Tuple(resultingType, p);
 }
コード例 #5
0
ファイル: Tuple.java プロジェクト: etcinitd/jalf
 /**
  * Fetches some attribute values and returns them as a list.
  *
  * @pre attrNames should only contain existing attributes.
  * @param attrNames some attribute names.
  * @return the list of values corresponding to the attribute names.
  */
 public List<Object> fetch(AttrList attrNames) {
   return attrNames.stream().map(a -> attrs.get(a)).collect(Collectors.toList());
 }