MATSIM
Public Member Functions | Private Attributes | List of all members
org.matsim.facilities.ActivityOptionImpl Class Reference
Inheritance diagram for org.matsim.facilities.ActivityOptionImpl:
Inheritance graph
[legend]

Public Member Functions

 ActivityOptionImpl (final String type)
 
void clearOpeningTimes ()
 
void addOpeningTime (OpeningTime opentime)
 
void setOpeningTimes (Collection< OpeningTime > times)
 
final void setCapacity (double capacity)
 
final String getType ()
 
final double getCapacity ()
 
final SortedSet< OpeningTimegetOpeningTimes ()
 
final String toString ()
 

Private Attributes

final String type
 
Double capacity = (double)Integer.MAX_VALUE
 
SortedSet< OpeningTimeopeningTimes = new TreeSet<>()
 

Detailed Description

Definition at line 28 of file ActivityOptionImpl.java.

Constructor & Destructor Documentation

◆ ActivityOptionImpl()

org.matsim.facilities.ActivityOptionImpl.ActivityOptionImpl ( final String  type)

Definition at line 34 of file ActivityOptionImpl.java.

References org.matsim.facilities.ActivityOptionImpl.type.

34  {
35  this.type = type;
36  }

Member Function Documentation

◆ clearOpeningTimes()

void org.matsim.facilities.ActivityOptionImpl.clearOpeningTimes ( )

◆ addOpeningTime()

void org.matsim.facilities.ActivityOptionImpl.addOpeningTime ( OpeningTime  opentime)

Implements org.matsim.facilities.ActivityOption.

Definition at line 43 of file ActivityOptionImpl.java.

References org.matsim.facilities.OpeningTime.getEndTime(), org.matsim.facilities.OpeningTime.getStartTime(), org.matsim.facilities.ActivityOptionImpl.openingTimes, org.matsim.facilities.OpeningTime.setEndTime(), and org.matsim.facilities.OpeningTime.setStartTime().

Referenced by org.matsim.facilities.ActivityOptionImpl.setOpeningTimes().

43  {
44  if (openingTimes.isEmpty()) {
45  openingTimes.add(opentime);
46  return;
47  }
48  TreeSet<OpeningTime> new_o_set = new TreeSet<>();
49  Iterator<OpeningTime> o_it = openingTimes.iterator();
50  while (o_it.hasNext()) {
51  OpeningTime o = o_it.next();
52  int merge_type = o.compareTo(opentime); // see Opentime for the meaning
53  if ((merge_type == -6) || (merge_type == 6)) {
54  // complete disjoint
55  new_o_set.add(o);
56  new_o_set.add(opentime);
57  }
58  else if ((merge_type >= -1) && (merge_type <= 2)) {
59  // opentime is subset of o
60  new_o_set.add(o);
61  }
62  else if ((merge_type == -3) || (merge_type == -2) || (merge_type == 3)) {
63  // o is subset of opentime
64  new_o_set.add(opentime);
65  }
66  else { // union of the two opentimes
67  if ((merge_type == -5) || (merge_type == -4)) {
68  // start_time of opentime and endtime of o
69  opentime.setEndTime(o.getEndTime());
70  new_o_set.add(opentime);
71  }
72  else if ((merge_type == 4) || (merge_type == 5)) {
73  // start_time of o and endtime of opentime
74  opentime.setStartTime(o.getStartTime());
75  new_o_set.add(opentime);
76  }
77  else {
78  throw new RuntimeException("[Something is wrong]");
79  }
80  }
81  }
82  this.openingTimes.clear();
83  this.openingTimes.addAll(new_o_set);
84  }
Here is the call graph for this function:

◆ setOpeningTimes()

void org.matsim.facilities.ActivityOptionImpl.setOpeningTimes ( Collection< OpeningTime times)

Definition at line 86 of file ActivityOptionImpl.java.

References org.matsim.facilities.ActivityOptionImpl.addOpeningTime(), and org.matsim.facilities.ActivityOptionImpl.clearOpeningTimes().

86  {
87  this.clearOpeningTimes();
88  for (OpeningTime t : times) {
89  this.addOpeningTime(t);
90  }
91  }
Here is the call graph for this function:

◆ setCapacity()

final void org.matsim.facilities.ActivityOptionImpl.setCapacity ( double  capacity)

Implements org.matsim.facilities.ActivityOption.

Definition at line 94 of file ActivityOptionImpl.java.

References org.matsim.facilities.ActivityOptionImpl.capacity.

94  {
95  if (capacity < 0) {
96  throw new NumberFormatException("A capacity of an activity must be >= 0.");
97  }
98  this.capacity = capacity;
99  }

◆ getType()

final String org.matsim.facilities.ActivityOptionImpl.getType ( )

◆ getCapacity()

final double org.matsim.facilities.ActivityOptionImpl.getCapacity ( )

◆ getOpeningTimes()

final SortedSet<OpeningTime> org.matsim.facilities.ActivityOptionImpl.getOpeningTimes ( )

◆ toString()

final String org.matsim.facilities.ActivityOptionImpl.toString ( )

Definition at line 117 of file ActivityOptionImpl.java.

References org.matsim.facilities.ActivityOptionImpl.getOpeningTimes().

117  {
118  return "[type=" + this.type + "]" +
119  "[capacity=" + this.capacity + "]" +
120  "[nof_opentimes=" + this.getOpeningTimes().size() + "]";
121  }
final SortedSet< OpeningTime > getOpeningTimes()
Here is the call graph for this function:

Member Data Documentation

◆ type

final String org.matsim.facilities.ActivityOptionImpl.type
private

◆ capacity

Double org.matsim.facilities.ActivityOptionImpl.capacity = (double)Integer.MAX_VALUE
private

◆ openingTimes

SortedSet<OpeningTime> org.matsim.facilities.ActivityOptionImpl.openingTimes = new TreeSet<>()
private

The documentation for this class was generated from the following file: