001/* Copyright (C) 2013 TU Dortmund 002 * This file is part of AutomataLib, http://www.automatalib.net/. 003 * 004 * AutomataLib is free software; you can redistribute it and/or 005 * modify it under the terms of the GNU Lesser General Public 006 * License version 3.0 as published by the Free Software Foundation. 007 * 008 * AutomataLib is distributed in the hope that it will be useful, 009 * but WITHOUT ANY WARRANTY; without even the implied warranty of 010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 011 * Lesser General Public License for more details. 012 * 013 * You should have received a copy of the GNU Lesser General Public 014 * License along with AutomataLib; if not, see 015 * http://www.gnu.de/documents/lgpl.en.html. 016 */ 017package net.automatalib.automata.graphs; 018 019import java.util.Objects; 020 021import net.automatalib.ts.UniversalTransitionSystem; 022 023public final class TransitionEdge<I, T> { 024 025 public static final class Property<I,TP> { 026 private final I input; 027 private final TP property; 028 029 030 public Property(I input, TP property) { 031 this.input = input; 032 this.property = property; 033 } 034 035 public I getInput() { 036 return input; 037 } 038 039 public TP getProperty() { 040 return property; 041 } 042 043 /* (non-Javadoc) 044 * @see java.lang.Object#hashCode() 045 */ 046 @Override 047 public int hashCode() { 048 final int prime = 31; 049 int result = 1; 050 result = prime * result + Objects.hashCode(input); 051 result = prime * result + Objects.hashCode(property); 052 return result; 053 } 054 055 /* (non-Javadoc) 056 * @see java.lang.Object#equals(java.lang.Object) 057 */ 058 @Override 059 public boolean equals(Object obj) { 060 if (this == obj) 061 return true; 062 if (obj == null) 063 return false; 064 if (obj.getClass() != Property.class) 065 return false; 066 Property<?,?> other = (Property<?,?>) obj; 067 if(!Objects.equals(input, other.input)) 068 return false; 069 return Objects.equals(property, other.property); 070 } 071 072 073 } 074 075 private final I input; 076 private final T transition; 077 078 public TransitionEdge(I input, T transition) { 079 this.input = input; 080 this.transition = transition; 081 } 082 083 084 public I getInput() { 085 return input; 086 } 087 088 public T getTransition() { 089 return transition; 090 } 091 092 093 public <TP> Property<I,TP> property(UniversalTransitionSystem<?, ?, T, ?, TP> uts) { 094 return new Property<>(input, uts.getTransitionProperty(transition)); 095 } 096 097 098 /* (non-Javadoc) 099 * @see java.lang.Object#hashCode() 100 */ 101 @Override 102 public int hashCode() { 103 final int prime = 31; 104 int result = 1; 105 result = prime * result + Objects.hashCode(input); 106 result = prime * result + Objects.hashCode(transition); 107 return result; 108 } 109 110 111 /* (non-Javadoc) 112 * @see java.lang.Object#equals(java.lang.Object) 113 */ 114 @Override 115 public boolean equals(Object obj) { 116 if (this == obj) 117 return true; 118 if (obj == null) 119 return false; 120 if (obj.getClass() != TransitionEdge.class) 121 return false; 122 TransitionEdge<?,?> other = (TransitionEdge<?,?>) obj; 123 if(!Objects.equals(input, other.input)) 124 return false; 125 return Objects.equals(transition, other.transition); 126 } 127 128 129 130}