uk.ac.soton.itinnovation.grid.service.types
Class Constraint

java.lang.Object
  extended by uk.ac.soton.itinnovation.grid.service.types.Constraint
All Implemented Interfaces:
Comparable<Constraint>

public class Constraint
extends Object
implements Comparable<Constraint>

Class to define all constraint types. In an SLATemplate, the startTime will not be defined as it is filled in when a proposal is accepted. If the duration is set and repeating is false, then it is a FixedConstraint and repeating is true, then it is an infinitely repeating PeriodicConstraint If the duration is not set it is an IndefiniteConstraint (value of repeating is irrelevent)


Field Summary
 Bound bound
           
 UsageType type
           
 
Constructor Summary
Constraint()
           
Constraint(Constraint c)
          Deprecated. 
Constraint(Metric metric, UsageType usageType, Bound bound, double limit, Calendar startTime)
           
 
Method Summary
 boolean canAccommodate(Constraint pConstraint, double used)
          Given a proposed constraint and the amount that has been used in this constraint, check if the proposed constraint can fit in this constraint.
 int compareTo(Constraint c)
           
 Constraint copyWithNullId()
          Copy the constraint without the hibernate id
 boolean equals(Object obj)
          Check if this object is equal to another object.
 GregorianCalendar[] findTimeSpan(Calendar time)
          Returns the start and end time of the repeating period that the given time falls in.
 String getBound()
           
 double getContention()
           
 TimePeriod getDuration()
           
 Long getId()
           
 double getLimit()
           
 Metric getMetric()
           
 Calendar getStartTime()
           
 String getType()
           
static TypeDesc getTypeDesc()
          Return type metadata object.
 boolean hasBreach(double amount)
          Return true if the amount passed in does not satisfy the Constraint's inequality.
 int hashCode()
          Calculate the hash code for this object.
 boolean isFixed()
           
 boolean isIndefinite()
           
 boolean isPeriodic()
           
 boolean isPrivate()
           
 boolean isRepeating()
           
 String prettyPrint()
           
 String prettyPrint(boolean html)
           
 void setBound(String argBound)
           
 void setContention(double argContention)
           
 void setDuration(TimePeriod argDuration)
           
 void setId(Long argId)
           
 void setLimit(double argLimit)
           
 void setMetric(Metric argMetric)
           
 void setPrivate(boolean argPriv)
           
 void setRepeating(boolean argRepeating)
           
 void setStartTime(Calendar argStartTime)
           
 void setType(String argType)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

bound

public Bound bound

type

public UsageType type
Constructor Detail

Constraint

public Constraint()

Constraint

public Constraint(Metric metric,
                  UsageType usageType,
                  Bound bound,
                  double limit,
                  Calendar startTime)

Constraint

@Deprecated
public Constraint(Constraint c)
Deprecated. 

Copy the constraint without the hibernate id

Method Detail

copyWithNullId

public Constraint copyWithNullId()
Copy the constraint without the hibernate id


getId

public Long getId()

setId

public void setId(Long argId)

getMetric

public Metric getMetric()

setMetric

public void setMetric(Metric argMetric)

getBound

public String getBound()

setBound

public void setBound(String argBound)

getType

public String getType()

setType

public void setType(String argType)

isPrivate

public boolean isPrivate()

setPrivate

public void setPrivate(boolean argPriv)

getLimit

public double getLimit()

setLimit

public void setLimit(double argLimit)

getContention

public double getContention()

setContention

public void setContention(double argContention)

getStartTime

public Calendar getStartTime()

setStartTime

public void setStartTime(Calendar argStartTime)

getDuration

public TimePeriod getDuration()

setDuration

public void setDuration(TimePeriod argDuration)

isRepeating

public boolean isRepeating()

setRepeating

public void setRepeating(boolean argRepeating)

prettyPrint

public String prettyPrint()

prettyPrint

public String prettyPrint(boolean html)

toString

public String toString()
Overrides:
toString in class Object

isIndefinite

public boolean isIndefinite()

isPeriodic

public boolean isPeriodic()

isFixed

public boolean isFixed()

findTimeSpan

public GregorianCalendar[] findTimeSpan(Calendar time)
Returns the start and end time of the repeating period that the given time falls in.


hasBreach

public boolean hasBreach(double amount)
Return true if the amount passed in does not satisfy the Constraint's inequality.


canAccommodate

public boolean canAccommodate(Constraint pConstraint,
                              double used)
Given a proposed constraint and the amount that has been used in this constraint, check if the proposed constraint can fit in this constraint.


equals

public boolean equals(Object obj)
Check if this object is equal to another object.

For the definition of the object equivalence relation see Object.equals(Object).

Overrides:
equals in class Object
Parameters:
obj - another, possibly equal object.
Returns:
true if the objects are equal, false otherwise.
See Also:
Object.equals(Object)

hashCode

public int hashCode()
Calculate the hash code for this object.

The rules laid out in J. Blosh's Effective Java are used for the hash code calculation.

Overrides:
hashCode in class Object
Returns:
the hash code.
See Also:
Object.hashCode()

compareTo

public int compareTo(Constraint c)
Specified by:
compareTo in interface Comparable<Constraint>

getTypeDesc

public static TypeDesc getTypeDesc()
Return type metadata object.



Copyright © 2001-2008 University of Southampton IT Innovation Centre. All Rights Reserved.