Class UnitRelation

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  UnitRelation.ID  
    • Field Summary

      Fields 
      Modifier and Type Field Description
      int line
      The line in the source's orders that is the cause for this relation.
      Unit origin
      The origin of this relation, normally the same as source.
      Problem problem  
      Unit source
      The source of this relation.
    • Constructor Summary

      Constructors 
      Constructor Description
      UnitRelation​(Unit source, int line)
      Creates a new UnitRelation object.
      UnitRelation​(Unit origin, Unit source, int line)
      Creates a new UnitRelation object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add()
      Attaches an order to all report objects it is relevant to.
      static UnitRelation.ID getClassID​(java.lang.Class<? extends UnitRelation> clazz)
      Returns a unique ID for every subclass of UnitRelation.
      boolean isRelated​(java.lang.Object object)
      Returns true if this relation somehow relates to the specified object.
      void setError​(java.lang.String string, ProblemType type)  
      void setWarning​(java.lang.String string, ProblemType type)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • origin

        public Unit origin
        The origin of this relation, normally the same as source. This is the unit that causes the relation.
        See Also:
        source
      • source

        public Unit source
        The source of this relation. This is the semantic origin of this relation.
      • line

        public int line
        The line in the source's orders that is the cause for this relation. The first line is 1.
    • Constructor Detail

      • UnitRelation

        public UnitRelation​(Unit origin,
                            Unit source,
                            int line)
        Creates a new UnitRelation object.
        Parameters:
        origin - The origin unit
        source - The source unit
        line - The line in the source's orders. The first line is 1.
      • UnitRelation

        public UnitRelation​(Unit source,
                            int line)
        Creates a new UnitRelation object.
        Parameters:
        source - The source unit
        line - The line in the source's orders
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getClassID

        public static UnitRelation.ID getClassID​(java.lang.Class<? extends UnitRelation> clazz)
        Returns a unique ID for every subclass of UnitRelation. The ID for a given class will always be the same for one run, but IDs may differ for different instances of this UnitRelation.class.
        Parameters:
        clazz - A subclass of UnitRelation.
        Returns:
        An ID that is unique for each class.
      • add

        public void add()
        Attaches an order to all report objects it is relevant to.
      • setWarning

        public void setWarning​(java.lang.String string,
                               ProblemType type)
      • setError

        public void setError​(java.lang.String string,
                             ProblemType type)
      • isRelated

        public boolean isRelated​(java.lang.Object object)
        Returns true if this relation somehow relates to the specified object. Subclasses should overwrite this method if they involve relations to other report objects.
        Parameters:
        object -
        Returns:
        true if the object is source or origin or otherwise affected by this relation