Exemple #1
0
 /**
  * Returns a new tuple by renaming some 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?
  *
  * @param r renaming function mapping old to new attribute names.
  * @pre `resultingType` should be faithful to the actual result, that it it must guarantee the
  *     post condition.
  * @return the renamed tuple.
  * @post `resultingType.contains(rename(r, resultingType))` is true
  */
 public Tuple rename(Renaming r, TupleType resultingType) {
   return new Tuple(resultingType, rekey(attrs, (k, v) -> r.apply(k)));
 }
Exemple #2
0
 @Test
 public void testItSupportsSuffixRenaming() {
   Renaming r = Renaming.suffix("foo");
   assertEquals(r.apply(sid), attr("sidfoo"));
 }
Exemple #3
0
 @Test
 public void testItSupportsPrefixRenaming() {
   Renaming r = Renaming.prefix("foo");
   assertEquals(r.apply(sid), attr("foosid"));
 }
Exemple #4
0
 @Test
 public void testItSupportsIntensionRenaming() {
   AttrName SID = attr("SID");
   Renaming r = Renaming.intension(a -> attr(a.getName().toUpperCase()));
   assertEquals(r.apply(sid), SID);
 }
Exemple #5
0
 @Test
 public void testExtensionRenamingIsTotal() {
   Renaming r = Renaming.extension(sid, ssid, name, sname);
   assertEquals(r.apply(city), city);
 }
Exemple #6
0
 @Test
 public void testItSupportsExtensionRenaming() {
   Renaming r = Renaming.extension(sid, ssid, name, sname);
   assertEquals(r.apply(sid), ssid);
   assertEquals(r.apply(name), sname);
 }