16de7ad4c9458c55fa9a1f8b77e66f27d6a5efd1
[mdsal.git] / binding / mdsal-binding-dom-codec / src / main / java / org / opendaylight / mdsal / binding / dom / codec / gen / spi / StaticConstantDefinition.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.mdsal.binding.dom.codec.gen.spi;
9
10 import com.google.common.base.Preconditions;
11
12 /**
13  * Definition of static property for generated class
14  * <p>
15  * This definition consists of
16  * <ul>
17  * <li>name - property name</li>
18  * <li>type - Java type for property</li>
19  * <li>value - value to which property should be initialized</li>
20  * </ul>
21  */
22 public class StaticConstantDefinition {
23
24     private final String name;
25     private final Class<?> type;
26     private final Object value;
27
28     public StaticConstantDefinition(final String name, final Class<?> type, final Object value) {
29         this.name = Preconditions.checkNotNull(name);
30         this.type = Preconditions.checkNotNull(type);
31         this.value = Preconditions.checkNotNull(value);
32     }
33
34     public String getName() {
35         return name;
36     }
37
38     public Class<?> getType() {
39         return type;
40     }
41
42     public Object getValue() {
43         return value;
44     }
45
46     @Override
47     public int hashCode() {
48         final int prime = 31;
49         int result = 1;
50         result = prime * result + name.hashCode();
51         return result;
52     }
53
54     @Override
55     public boolean equals(final Object obj) {
56         if (this == obj) {
57             return true;
58         }
59         if (obj == null) {
60             return false;
61         }
62         if (getClass() != obj.getClass()) {
63             return false;
64         }
65         StaticConstantDefinition other = (StaticConstantDefinition) obj;
66         if (!name.equals(other.name)) {
67             return false;
68         }
69         return true;
70     }
71
72 }