// Copyright (C) 2008-2009 Christian M. Zmasek
// Copyright (C) 2008-2009 Burnham Institute for Medical Research
// All rights reserved
-//
+//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
-//
+//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
//
// Contact: phylosoft @ gmail . com
-// WWW: www.phylosoft.org/forester
+// WWW: https://sites.google.com/site/cmzmasek/home/software/forester
package org.forester.surfacing;
+import org.forester.protein.BinaryDomainCombination;
import org.forester.util.ForesterUtil;
public class BasicBinaryDomainCombination implements BinaryDomainCombination {
- DomainId _id_0;
- DomainId _id_1;
+ String _id0;
+ String _id1;
+ String _str;
BasicBinaryDomainCombination() {
- _id_0 = null;
- _id_1 = null;
+ _id0 = null;
+ _id1 = null;
}
- public BasicBinaryDomainCombination( final DomainId id_0, final DomainId id_1 ) {
- if ( ( id_0 == null ) || ( id_1 == null ) ) {
+ private String getAsStr() {
+ return _id0 + SEPARATOR + _id1;
+ }
+
+ public BasicBinaryDomainCombination( final String id0, final String id1 ) {
+ if ( ( id0 == null ) || ( id1 == null ) ) {
throw new IllegalArgumentException( "attempt to create binary domain combination using null" );
}
- if ( id_0.compareTo( id_1 ) < 0 ) {
- _id_0 = id_0;
- _id_1 = id_1;
+ if ( id0.toLowerCase().compareTo( id1.toLowerCase() ) < 0 ) {
+ _id0 = id0;
+ _id1 = id1;
}
else {
- _id_0 = id_1;
- _id_1 = id_0;
+ _id0 = id1;
+ _id1 = id0;
}
}
- public BasicBinaryDomainCombination( final String id_0, final String id_1 ) {
- this( new DomainId( id_0 ), new DomainId( id_1 ) );
- }
-
@Override
public int compareTo( final BinaryDomainCombination binary_domain_combination ) {
if ( binary_domain_combination.getClass() != this.getClass() ) {
}
}
- public DomainId getId0() {
- return _id_0;
+ @Override
+ public String getId0() {
+ return _id0;
}
- public DomainId getId1() {
- return _id_1;
+ @Override
+ public String getId1() {
+ return _id1;
}
@Override
public int hashCode() {
- return getId0().hashCode() + ( 19 * getId1().hashCode() );
+ return getAsStr().hashCode();
}
+ @Override
public StringBuffer toGraphDescribingLanguage( final OutputFormat format,
final String node_attribute,
final String edge_attribute ) {
@Override
public String toString() {
- final StringBuffer sb = new StringBuffer();
- sb.append( getId0() );
- sb.append( BinaryDomainCombination.SEPARATOR );
- sb.append( getId1() );
- return sb.toString();
+ return getAsStr();
}
public static BinaryDomainCombination createInstance( final String ids ) {