### Question:
Segment { public boolean matches( Segment that ) { if( getClass().isInstance( that ) ) { for( Value thisValue: this.values.values() ) { for( Value thatValue: that.values.values() ) { if( thisValue.matches( thatValue ) ) { return true; } } } } return false; } 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 testMatches() throws Exception { TestSegment s1 = new TestSegment( "p", "v", true ); TestSegment s2 = new TestSegment( "p", "v", true ); assertThat( s1.matches( s1 ), equalTo( true ) ); assertThat( s1.matches( s2 ), equalTo( true ) ); TestSegment s3 = new TestSegment( "p", "*", false ); assertThat( s3.matches( s1 ), equalTo( true ) ); assertThat( s1.matches( s3 ), equalTo( false ) ); TestSegment s4 = new TestSegment( "p", "**", false ); assertThat( s4.matches( s1 ), equalTo( true ) ); assertThat( s1.matches( s4 ), equalTo( false ) ); TestSegment s5 = new TestSegment( "p", "*.ext", false ); TestSegment s6 = new TestSegment( "p", "file.ext", false ); assertThat( s5.matches( s5 ), equalTo( true ) ); assertThat( s5.matches( s6 ), equalTo( true ) ); assertThat( s6.matches( s5 ), equalTo( false ) ); assertThat( s3.matches( s4 ), equalTo( true ) ); assertThat( s4.matches( s3 ), equalTo( true ) ); assertThat( s3.matches( s5 ), equalTo( true ) ); assertThat( s5.matches( s3 ), equalTo( false ) ); assertThat( s4.matches( s5 ), equalTo( true ) ); assertThat( s5.matches( s4 ), equalTo( false ) ); }