Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2009 Future Invent Informationsmanagement GmbH. All rights reserved. <http://www.fuin.org/> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see <http://www.gnu.org/licenses/>.
 
 package org.fuin.units4j.dependency;
 
 import java.util.List;
 
 
 // CHECKSTYLE:OFF
Package and it's allowed or disallowed dependencies (this depends on the context of this object. Two objects are considered equal if the names are equal.

Parameters:
<DEP_TYPE> Type of dependency.
 
 // CHECKSTYLE:ON
 public final class Package<DEP_TYPE extends Dependencyimplements ToDebugStringCapable {
 
     private final String name;
 
     private final String comment;
 
     private final List<DEP_TYPE> dependencies;

    
Constructor with name.

Parameters:
name Name of the package - Cannot be null.
 
     public Package(final String name) {
         this(namenull);
     }

    
Constructor with name and comment.

Parameters:
name Name of the package - Cannot be null.
comment Comment why restrictions apply.
 
     public Package(final String namefinal String comment) {
         super();
         Utils4J.checkNotNull("name"name);
         this. = name;
         this. = comment;
         this. = new ArrayList<DEP_TYPE>();
     }

    
Returns the package name.

Returns:
Name of the package.
 
     public final String getName() {
         return ;
     }

    
Returns the list of related packages.

Returns:
List of package dependencies.
 
     public final List<DEP_TYPE> getDependencies() {
         if ( == null) {
             // This can only happen with serialization
             return Collections.emptyList();
         }
         return ;
     }

    
 
     @Override
     public int hashCode() {
         final int prime = 31;
         int result = 1;
        // CHECKSTYLE:OFF
        result = prime * result + (( == null) ? 0 : .hashCode());
        // CHECKSTYLE:ON
        return result;
    }

    
    @Override
    public boolean equals(final Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Package<?> other = (Package<?>) obj;
        if ( == null) {
            if (other.name != null) {
                return false;
            }
        } else if (!.equals(other.name)) {
            return false;
        }
        return true;
    }

    
Returns a comment why restrictions apply.

Returns:
Description of the restriction for all dependencies in the package.
    public final String getComment() {
        return ;
    }

    
    @Override
    public final String toString() {
        return ;
    }

    
    public String toDebugString() {
        final StringBuffer sb = new StringBuffer();
        sb.append("name=" +  + ", ");
        sb.append("comment=" +  + ", ");
        sb.append("dependencies={");
        final List<DEP_TYPE> list = getDependencies();
        for (int i = 0; i < list.size(); i++) {
            if (i > 0) {
                sb.append(", ");
            }
            sb.append(list.get(i));
        }
        sb.append("}");
        return sb.toString();
    }
New to GrepCode? Check out our FAQ X