### Question:
Segment { @Override @SuppressWarnings( "unchecked" ) public boolean equals( Object obj ) { boolean equal = false; if( obj instanceof Segment ) { Segment that = (Segment)obj; equal = ( this.token.parameterName.equals( that.token.parameterName ) && this.values.size() == that.values.size() ); if( equal ) { for( String pattern: this.values.keySet() ) { equal = that.values.containsKey( pattern ); if( !equal ) { break; } } } } return equal; } protected  Segment( Token token ); @Override int hashCode(); @Override @SuppressWarnings( "unchecked" ) boolean equals( Object obj ); String getParamName(); Collection<Value> getValues(); Value getFirstValue(); boolean matches( Segment that ); @Override String toString(); static final int STATIC; static final int REGEX; static final int STAR; static final int DEFAULT; static final int GLOB; static final int UNKNOWN; }### Answer:
@Test public void testEquals() throws Exception { Object o = new Object(); TestSegment s1 = new TestSegment( "p", "v", true ); assertThat( s1.equals( o ), equalTo( false ) ); assertThat( s1.equals( s1 ), equalTo( true ) ); TestSegment s2 = new TestSegment( "p", "v", true ); assertThat( s1.equals( s2 ), equalTo( true ) ); TestSegment s3 = new TestSegment( "p2", "v", true ); assertThat( s2.equals( s3 ), equalTo( false ) ); TestSegment s4 = new TestSegment( "p2", "v2", true ); assertThat( s3.equals( s4 ), equalTo( false ) ); TestSegment s5 = new TestSegment( "p", "*", false ); assertThat( s1.equals( s5 ), equalTo( false ) ); }