diff options
Diffstat (limited to 'src/cuchaz/enigma/mapping/FieldEntry.java')
| -rw-r--r-- | src/cuchaz/enigma/mapping/FieldEntry.java | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/cuchaz/enigma/mapping/FieldEntry.java b/src/cuchaz/enigma/mapping/FieldEntry.java new file mode 100644 index 0000000..15a9352 --- /dev/null +++ b/src/cuchaz/enigma/mapping/FieldEntry.java | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2014 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Public License v3.0 | ||
| 5 | * which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/gpl.html | ||
| 7 | * | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | package cuchaz.enigma.mapping; | ||
| 12 | |||
| 13 | import java.io.Serializable; | ||
| 14 | |||
| 15 | import cuchaz.enigma.Util; | ||
| 16 | |||
| 17 | public class FieldEntry implements Serializable | ||
| 18 | { | ||
| 19 | private static final long serialVersionUID = 3004663582802885451L; | ||
| 20 | |||
| 21 | private ClassEntry m_classEntry; | ||
| 22 | private String m_name; | ||
| 23 | |||
| 24 | public FieldEntry( ClassEntry classEntry, String name ) | ||
| 25 | { | ||
| 26 | if( classEntry == null ) | ||
| 27 | { | ||
| 28 | throw new IllegalArgumentException( "Class cannot be null!" ); | ||
| 29 | } | ||
| 30 | if( name == null ) | ||
| 31 | { | ||
| 32 | throw new IllegalArgumentException( "Field name cannot be null!" ); | ||
| 33 | } | ||
| 34 | |||
| 35 | m_classEntry = classEntry; | ||
| 36 | m_name = name; | ||
| 37 | } | ||
| 38 | |||
| 39 | public ClassEntry getClassEntry( ) | ||
| 40 | { | ||
| 41 | return m_classEntry; | ||
| 42 | } | ||
| 43 | |||
| 44 | public String getName( ) | ||
| 45 | { | ||
| 46 | return m_name; | ||
| 47 | } | ||
| 48 | |||
| 49 | @Override | ||
| 50 | public int hashCode( ) | ||
| 51 | { | ||
| 52 | return Util.combineHashesOrdered( m_classEntry, m_name ); | ||
| 53 | } | ||
| 54 | |||
| 55 | @Override | ||
| 56 | public boolean equals( Object other ) | ||
| 57 | { | ||
| 58 | if( other instanceof FieldEntry ) | ||
| 59 | { | ||
| 60 | return equals( (FieldEntry)other ); | ||
| 61 | } | ||
| 62 | return false; | ||
| 63 | } | ||
| 64 | |||
| 65 | public boolean equals( FieldEntry other ) | ||
| 66 | { | ||
| 67 | return m_classEntry.equals( other.m_classEntry ) | ||
| 68 | && m_name.equals( other.m_name ); | ||
| 69 | } | ||
| 70 | |||
| 71 | @Override | ||
| 72 | public String toString( ) | ||
| 73 | { | ||
| 74 | return m_classEntry.getName() + "." + m_name; | ||
| 75 | } | ||
| 76 | } | ||