
net.automatalib.brics.BricsTransitionProperty Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of automata-brics Show documentation
Show all versions of automata-brics Show documentation
This artifact contains adapter classes for treating the Automaton objects from the
BRICS library (http://www.brics.dk/automaton) as AutomataLib models.
/* Copyright (C) 2013 TU Dortmund
* This file is part of AutomataLib, http://www.automatalib.net/.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.automatalib.brics;
import dk.brics.automaton.Transition;
/**
* The properties of an edge in a Brics automaton.
*
* @author Malte Isberner
*/
public class BricsTransitionProperty {
public static String toString(char min, char max) {
StringBuilder sb = new StringBuilder();
sb.append('\'').append(min).append('\'');
if(max > min)
sb.append("..'").append(max).append('\'');
return sb.toString();
}
private final char min;
private final char max;
/**
* Constructor.
* @param min lower bound of the character range.
* @param max upper bound of the character range.
*/
public BricsTransitionProperty(char min, char max) {
this.min = min;
this.max = max;
}
/**
* Constructor. Constructs the property from a Brics {@link Transition}.
* @param trans the Brics transition object
*/
public BricsTransitionProperty(Transition trans) {
this(trans.getMin(), trans.getMax());
}
/**
* Retrieves the lower bound of the character range.
* @return the lower bound of the character range
* @see Transition#getMin()
*/
public char getMin() {
return min;
}
/**
* Retrieves the upper bound of the character range.
* @return the upper bound of the character range
* @see Transition#getMax()
*/
public char getMax() {
return max;
}
/*
* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + max;
result = prime * result + min;
return result;
}
/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
BricsTransitionProperty other = (BricsTransitionProperty) obj;
if (max != other.max)
return false;
if (min != other.min)
return false;
return true;
}
/*
* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return toString(min, max);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy