Coverage Report - org.kuali.rice.krms.api.Asset
 
Classes in this File Line Coverage Branch Coverage Complexity
Asset
0%
0/30
0%
0/24
3.5
 
 1  
 package org.kuali.rice.krms.api;
 2  
 
 3  
 /**
 4  
  * identifies a (hopefully) resolvable asset
 5  
  * @author gilesp
 6  
  *
 7  
  */
 8  0
 public final class Asset implements Comparable<Asset> {
 9  
         
 10  
         private final String name;
 11  
         private final String type;
 12  
         private final String comparatorHelper;
 13  
         
 14  0
         public Asset(String name, String type) {
 15  0
                 if (name == null) throw new IllegalArgumentException("name is required");
 16  0
                 if (name.contains("!")) throw new IllegalArgumentException("name contains illegal character '!'");
 17  0
                 if (type == null) throw new IllegalArgumentException("type is required");
 18  0
                 if (type.contains("!")) throw new IllegalArgumentException("type contains illegal character '!'");
 19  0
                 this.name = name;
 20  0
                 this.type = type;
 21  
                 // for lexicographic total ordering
 22  0
                 this.comparatorHelper = name + "!" + type;
 23  0
         }
 24  
         
 25  0
         public String getName() { return name; }
 26  0
         public String getType() { return type; }
 27  
 
 28  
         /* (non-Javadoc)
 29  
          * @see java.lang.Object#hashCode()
 30  
          */
 31  
         @Override
 32  
         public int hashCode() {
 33  0
                 final int prime = 31;
 34  0
                 int result = 1;
 35  0
                 result = prime * result + ((name == null) ? 0 : name.hashCode());
 36  0
                 result = prime * result + ((type == null) ? 0 : type.hashCode());
 37  0
                 return result;
 38  
         }
 39  
 
 40  
         /* (non-Javadoc)
 41  
          * @see java.lang.Object#equals(java.lang.Object)
 42  
          */
 43  
         @Override
 44  
         public boolean equals(Object obj) {
 45  0
                 if (this == obj)
 46  0
                         return true;
 47  0
                 if (obj == null)
 48  0
                         return false;
 49  0
                 if (getClass() != obj.getClass())
 50  0
                         return false;
 51  0
                 Asset other = (Asset) obj;
 52  0
                 return this.compareTo(other) == 0;
 53  
         }
 54  
 
 55  
         @Override
 56  
         public int compareTo(Asset o) {
 57  0
                 if (o == null) return 1;
 58  0
                 if (this == o) return 0;
 59  0
                 return (comparatorHelper.compareTo(o.comparatorHelper));
 60  
         }
 61  
         
 62  
         public String getComparatorHelper() {
 63  0
                 return comparatorHelper;
 64  
         }
 65  
 
 66  
         @Override
 67  
         public String toString() {
 68  
                 // TODO make this pretty
 69  0
                 return getClass().getSimpleName()+"("+getComparatorHelper()+")";
 70  
         }
 71  
         
 72  
 }