MATSIM
FailingObjectAttributes.java
Go to the documentation of this file.
1 package org.matsim.utils.objectattributes;
2 
3 import java.util.function.Function;
4 
5 @Deprecated // for refactoring only
7  private final Function<String, String> msgFunction;
8 
9  // This is only meant as a transitory refactoring device. For this reason,
10  // all "specialized" versions are created in static methods in this class,
11  // to keep it all contained here
12  private FailingObjectAttributes(Function<String, String> msgFunction) {
13  this.msgFunction = msgFunction;
14  }
15 
17  return new FailingObjectAttributes(
18  str -> "population.getPersonAttributes()." + str + " will be deprecated; use PopulationUtils" +
19  ".get/put/...PersonAttribute... instead. kai, may'19"
20  );
21  }
22 
24  return new FailingObjectAttributes(
25  str -> "facilities.getPersonAttributes()." + str + " will be deprecated; use FacilitiesUtils" +
26  ".get/put/...FacilityAttribute... instead. td, aug'19"
27  );
28  }
29 
31  return new FailingObjectAttributes(
32  str -> "households.getHouseholdAttributes()." + str + " will be deprecated; use HouseholdUtils" +
33  ".get/put/...HouseholdAttribute... instead. td, aug'19"
34  );
35  }
36 
38  return new FailingObjectAttributes(
39  str -> "schedule.getTransitStopsAttributes()." + str + " will be deprecated; use TransitScheduleUtils" +
40  ".get/put/...Attribute... instead. td, aug'19"
41  );
42  }
43 
45  return new FailingObjectAttributes(
46  str -> "schedule.getTransitLinesAttributes()." + str + " will be deprecated; use TransitScheduleUtils" +
47  ".get/put/...Attribute... instead. td, aug'19"
48  );
49  }
50 
51  @Override public Object getAttribute( String personId, String key) {
52  throw new RuntimeException( msgFunction.apply("getAttribute"));
53  }
54  @Override public Object putAttribute( String personId, String key, Object value) {
55  throw new RuntimeException( msgFunction.apply("putAttribute"));
56  }
57  @Override public Object removeAttribute( String personId, String key ) {
58  throw new RuntimeException( msgFunction.apply("removeAttribute"));
59  }
60  @Override public void removeAllAttributes( String personId ) {
61  throw new RuntimeException( msgFunction.apply("removeAllAttributes"));
62  }
63  @Override public void clear() {
64  throw new RuntimeException( msgFunction.apply( "clear"));
65  }
66  @Override public String toString() {
67  return super.toString() ;
68  }
69 
70  // for retrofitting. Called from PopulationUtils only. Remove eventually. kai, may'19
71  Object getAttributeDirectly( String personId, String key ){
72  return super.getAttribute( personId, key ) ;
73  }
74  Object removeAttributeDirectly( String personId, String key ){
75  return super.removeAttribute( personId, key ) ;
76  }
77  void removeAllAttributesDirectly( String personId ) {
78  super.removeAllAttributes( personId );
79  }
80 }
FailingObjectAttributes(Function< String, String > msgFunction)
Object putAttribute(String personId, String key, Object value)