public DefaultPeriod(Instant begining, Instant ending) { if (begining.relativePosition(ending).equals(RelativePosition.BEFORE)) { this.begining = begining; this.ending = ending; } /*if (((DefaultInstant) begining).getPosition().getDate().before(((DefaultInstant) ending).getPosition().getDate())) { this.begining = begining; this.ending = ending; } */ else { throw new IllegalArgumentException( "The temporal position of the beginning of the period must be less than (i.e. earlier than) the temporal position of the end of the period"); } }
/** Returns the list of enumerations of the same kind than this enum. */ public RelativePosition[] family() { return values(); }
/** * Returns the relative position that matches the given string, or returns a new one if none * match it. * * @param code The name of the code to fetch or to create. * @return A code matching the given name. */ public static RelativePosition valueOf(String code) { return valueOf(RelativePosition.class, code); } }
/** * Returns the RelativePosition that matches the given string, or returns a * new one if none match it. */ public static RelativePosition valueOf(String code) { if (code == null) { return null; } synchronized (VALUES) { Iterator iter = VALUES.iterator(); while (iter.hasNext()) { RelativePosition type = (RelativePosition) iter.next(); if (code.equalsIgnoreCase(type.name())) { return type; } } return new RelativePosition(code); } } }
if (this.relativePosition(other).equals(RelativePosition.BEFORE) || this.relativePosition(other).equals(RelativePosition.AFTER)) { if (this instanceof Instant && other instanceof Instant) { diff = if (this.relativePosition(other).equals(RelativePosition.BEGINS) || this.relativePosition(other).equals(RelativePosition.BEGUN_BY) || this.relativePosition(other).equals(RelativePosition.CONTAINS) || this.relativePosition(other).equals(RelativePosition.DURING) || this.relativePosition(other).equals(RelativePosition.ENDED_BY) || this.relativePosition(other).equals(RelativePosition.ENDS) || this.relativePosition(other).equals(RelativePosition.EQUALS) || this.relativePosition(other).equals(RelativePosition.MEETS) || this.relativePosition(other).equals(RelativePosition.MET_BY) || this.relativePosition(other).equals(RelativePosition.OVERLAPPED_BY) || this.relativePosition(other).equals(RelativePosition.OVERLAPS)) { diff = 0L;
/** * Returns the list of enumerations of the same kind than this enum. */ public /*RelativePosition[]*/ CodeList[] family() { return values(); }
/** * Returns the relative position that matches the given string, or returns a * new one if none match it. More specifically, this methods returns the first instance for * which <code>{@linkplain #name() name()}.{@linkplain String#equals equals}(code)</code> * returns {@code true}. If no existing instance is found, then a new one is created for * the given name. * * @param code the name of the code to fetch or to create. * @return a code matching the given name. */ public static RelativePosition valueOf(String code) { return valueOf(RelativePosition.class, code); } }
/** Test of relativePosition method, of class DefaultTemporalPrimitive. */ @Test public void testRelativePosition() { TemporalPrimitive other; // relative position between Instant objects cal.set(2000, 0, 1); Position position = new DefaultPosition(cal.getTime()); other = new DefaultInstant(position); RelativePosition result = temporalPrimitive1.relativePosition(other); assertFalse(temporalPrimitive2.relativePosition(other).equals(result)); // relative position between Instant and Period Instant instant1 = new DefaultInstant(new DefaultPosition(cal.getTime())); Instant instant2 = (DefaultInstant) temporalPrimitive2; other = new DefaultPeriod(instant1, instant2); result = temporalPrimitive1.relativePosition(other); assertFalse(temporalPrimitive2.relativePosition(other).equals(result)); // relative position between Period onbjects temporalPrimitive1 = new DefaultPeriod(new DefaultInstant(position1), instant1); cal.set(2200, 9, 1); temporalPrimitive2 = new DefaultPeriod(instant2, new DefaultInstant(new DefaultPosition(cal.getTime()))); result = temporalPrimitive1.relativePosition(other); assertFalse(temporalPrimitive2.relativePosition(other).equals(result)); } }
/** * Returns the list of codes of the same kind than this code list element. * Invoking this method is equivalent to invoking {@link #values()}, except that * this method can be invoked on an instance of the parent {@code CodeList} class. * * @return all code {@linkplain #values() values} for this code list. */ @Override public RelativePosition[] family() { return values(); }
public DefaultPeriod(Instant begining, Instant ending) { if (begining.relativePosition(ending).equals(RelativePosition.BEFORE)) { this.begining = begining; this.ending = ending; } /*if (((DefaultInstant) begining).getPosition().getDate().before(((DefaultInstant) ending).getPosition().getDate())) { this.begining = begining; this.ending = ending; } */else { throw new IllegalArgumentException("The temporal position of the beginning of the period must be less than (i.e. earlier than) the temporal position of the end of the period"); } }
public DefaultPeriod(Instant begining, Instant ending) { if (begining.relativePosition(ending).equals(RelativePosition.BEFORE)) { this.begining = begining; this.ending = ending; } /*if (((DefaultInstant) begining).getPosition().getDate().before(((DefaultInstant) ending).getPosition().getDate())) { this.begining = begining; this.ending = ending; } */else { throw new IllegalArgumentException("The temporal position of the beginning of the period must be less than (i.e. earlier than) the temporal position of the end of the period"); } }
if (this.relativePosition(other).equals(RelativePosition.BEFORE) || this.relativePosition(other).equals(RelativePosition.AFTER)) { if (this instanceof Instant && other instanceof Instant) { diff = Math.min(Math.abs(((Instant) other).getPosition().getDate().getTime() - ((Instant) this).getPosition().getDate().getTime()), if (this.relativePosition(other).equals(RelativePosition.BEGINS) || this.relativePosition(other).equals(RelativePosition.BEGUN_BY) || this.relativePosition(other).equals(RelativePosition.CONTAINS) || this.relativePosition(other).equals(RelativePosition.DURING) || this.relativePosition(other).equals(RelativePosition.ENDED_BY) || this.relativePosition(other).equals(RelativePosition.ENDS) || this.relativePosition(other).equals(RelativePosition.EQUALS) || this.relativePosition(other).equals(RelativePosition.MEETS) || this.relativePosition(other).equals(RelativePosition.MET_BY) || this.relativePosition(other).equals(RelativePosition.OVERLAPPED_BY) || this.relativePosition(other).equals(RelativePosition.OVERLAPS)) {
if (this.relativePosition(other).equals(RelativePosition.BEFORE) || this.relativePosition(other).equals(RelativePosition.AFTER)) { if (this instanceof Instant && other instanceof Instant) { diff = Math.min(Math.abs(((Instant) other).getPosition().getDate().getTime() - ((Instant) this).getPosition().getDate().getTime()), if (this.relativePosition(other).equals(RelativePosition.BEGINS) || this.relativePosition(other).equals(RelativePosition.BEGUN_BY) || this.relativePosition(other).equals(RelativePosition.CONTAINS) || this.relativePosition(other).equals(RelativePosition.DURING) || this.relativePosition(other).equals(RelativePosition.ENDED_BY) || this.relativePosition(other).equals(RelativePosition.ENDS) || this.relativePosition(other).equals(RelativePosition.EQUALS) || this.relativePosition(other).equals(RelativePosition.MEETS) || this.relativePosition(other).equals(RelativePosition.MET_BY) || this.relativePosition(other).equals(RelativePosition.OVERLAPPED_BY) || this.relativePosition(other).equals(RelativePosition.OVERLAPS)) {