Switch to Objects.requireNonNull
[mdsal.git] / binding2 / mdsal-binding2-dom-codec / src / main / java / org / opendaylight / mdsal / binding / javav2 / dom / codec / generator / impl / StaticBindingProperty.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.javav2.dom.codec.generator.impl;
9
10 import static java.util.Objects.requireNonNull;
11
12 import com.google.common.annotations.Beta;
13
14 /**
15  * Definition of static property for Binding objects.
16  *
17  * <p>
18  * This definition consists of
19  * <ul>
20  * <li>name - property name</li>
21  * <li>type - Java type for property</li>
22  * <li>value - value to which property should be initialized</li>
23  * </ul>
24  */
25 @Beta
26 public class StaticBindingProperty {
27
28     private final String name;
29     private final Class<?> type;
30     private final Object value;
31
32     public StaticBindingProperty(final String name, final Class<?> type, final Object value) {
33         this.name = requireNonNull(name);
34         this.type = requireNonNull(type);
35         this.value = requireNonNull(value);
36     }
37
38     public String getName() {
39         return this.name;
40     }
41
42     public Class<?> getType() {
43         return this.type;
44     }
45
46     public Object getValue() {
47         return this.value;
48     }
49
50     @Override
51     public int hashCode() {
52         final int prime = 31;
53         int result = 1;
54         result = prime * result + this.name.hashCode();
55         return result;
56     }
57
58     @Override
59     public boolean equals(final Object obj) {
60         if (this == obj) {
61             return true;
62         }
63         if (obj == null) {
64             return false;
65         }
66         if (getClass() != obj.getClass()) {
67             return false;
68         }
69         final StaticBindingProperty other = (StaticBindingProperty) obj;
70         if (!this.name.equals(other.name)) {
71             return false;
72         }
73         return true;
74     }
75 }