Coverage Report - org.yaml.snakeyaml.introspector.Property
 
Classes in this File Line Coverage Branch Coverage Complexity
Property
75%
12/16
0%
0/6
1.25
 
 1  
 /**
 2  
  * Copyright (c) 2008-2012, http://www.snakeyaml.org
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.yaml.snakeyaml.introspector;
 17  
 
 18  
 /**
 19  
  * <p>
 20  
  * A <code>Property</code> represents a single member variable of a class,
 21  
  * possibly including its accessor methods (getX, setX). The name stored in this
 22  
  * class is the actual name of the property as given for the class, not an
 23  
  * alias.
 24  
  * </p>
 25  
  * 
 26  
  * <p>
 27  
  * Objects of this class have a total ordering which defaults to ordering based
 28  
  * on the name of the property.
 29  
  * </p>
 30  
  */
 31  87857
 public abstract class Property implements Comparable<Property> {
 32  
 
 33  
     private final String name;
 34  
     private final Class<?> type;
 35  
 
 36  58492
     public Property(String name, Class<?> type) {
 37  58492
         this.name = name;
 38  58492
         this.type = type;
 39  58492
     }
 40  
 
 41  
     public Class<?> getType() {
 42  24755
         return type;
 43  
     }
 44  
 
 45  
     abstract public Class<?>[] getActualTypeArguments();
 46  
 
 47  
     public String getName() {
 48  173812
         return name;
 49  
     }
 50  
 
 51  
     @Override
 52  
     public String toString() {
 53  1
         return getName() + " of " + getType();
 54  
     }
 55  
 
 56  
     public int compareTo(Property o) {
 57  87859
         return name.compareTo(o.name);
 58  
     }
 59  
 
 60  
     public boolean isWritable() {
 61  57267
         return true;
 62  
     }
 63  
 
 64  
     public boolean isReadable() {
 65  57105
         return true;
 66  
     }
 67  
 
 68  
     abstract public void set(Object object, Object value) throws Exception;
 69  
 
 70  
     abstract public Object get(Object object);
 71  
 
 72  
     @Override
 73  
     public int hashCode() {
 74  8
         return name.hashCode() + type.hashCode();
 75  
     }
 76  
 
 77  
     @Override
 78  
     public boolean equals(Object other) {
 79  0
         if (other instanceof Property) {
 80  0
             Property p = (Property) other;
 81  0
             return name.equals(p.getName()) && type.equals(p.getType());
 82  
         }
 83  0
         return false;
 84  
     }
 85  
 }