CacheConcurrencyStrategy ccs; if ( AccessType.READ_ONLY.equals( accessType ) ) { if ( metadata.isMutable() ) { log.warn( "read-only cache configured for mutable collection [" + getName() + "]" ); } ccs = new ReadOnlyCache(); } else if ( AccessType.READ_WRITE.equals( accessType ) ) { ccs = new ReadWriteCache(); } else if ( AccessType.NONSTRICT_READ_WRITE.equals( accessType ) ) { ccs = new NonstrictReadWriteCache(); } else if ( AccessType.TRANSACTIONAL.equals( accessType ) ) { ccs = new TransactionalCache(); } else { throw new IllegalArgumentException( "unrecognized access strategy type [" + accessType + "]" ); } ccs.setCache( underlyingCache ); return new CollectionAccessStrategyAdapter( this, ccs, settings );
CacheConcurrencyStrategy ccs; if ( AccessType.READ_ONLY.equals( accessType ) ) { if ( metadata.isMutable() ) { log.warn( "read-only cache configured for mutable entity [" + getName() + "]" ); } ccs = new ReadOnlyCache(); } else if ( AccessType.READ_WRITE.equals( accessType ) ) { ccs = new ReadWriteCache(); } else if ( AccessType.NONSTRICT_READ_WRITE.equals( accessType ) ) { ccs = new NonstrictReadWriteCache(); } else if ( AccessType.TRANSACTIONAL.equals( accessType ) ) { ccs = new TransactionalCache(); } else { throw new IllegalArgumentException( "unrecognized access strategy type [" + accessType + "]" ); } ccs.setCache( underlyingCache ); return new EntityAccessStrategyAdapter( this, ccs, settings );
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/cache/impl/bridge/CollectionRegionAdapter.java File path: /hibernate-distribution-3.3.2.GA/project/core/src/main/java/org/hibernate/cache/impl/bridge/EntityRegionAdapter.java
Method name: CollectionRegionAccessStrategy buildAccessStrategy(AccessType) Method name: EntityRegionAccessStrategy buildAccessStrategy(AccessType)
Number of AST nodes: 14 Number of AST nodes: 14
1
CacheConcurrencyStrategy ccs;
1
CacheConcurrencyStrategy ccs;
2
		if ( AccessType.READ_ONLY.equals( accessType ) ) {
2
		if ( AccessType.READ_ONLY.equals( accessType ) ) {
3
			if ( metadata.isMutable() ) {
3
			if ( metadata.isMutable() ) {
4
				log.warn( "read-only cache configured for mutable collection [" + getName() + "]" );
4
				log.warn( "read-only cache configured for mutable entity [" + getName() + "]" );
5
			}
5
			}
6
			ccs = new ReadOnlyCache();
6
			ccs = new ReadOnlyCache();
7
		}
7
		}
8
		else if ( AccessType.READ_WRITE.equals( accessType ) ) {
8
		else if ( AccessType.READ_WRITE.equals( accessType ) ) {
9
			ccs = new ReadWriteCache();
9
			ccs = new ReadWriteCache();
10
		}
10
		}
11
		else if ( AccessType.NONSTRICT_READ_WRITE.equals( accessType ) ) {
11
		else if ( AccessType.NONSTRICT_READ_WRITE.equals( accessType ) ) {
12
			ccs = new NonstrictReadWriteCache();
12
			ccs = new NonstrictReadWriteCache();
13
		}
13
		}
14
		else if ( AccessType.TRANSACTIONAL.equals( accessType ) ) {
14
		else if ( AccessType.TRANSACTIONAL.equals( accessType ) ) {
15
			ccs = new TransactionalCache();
15
			ccs = new TransactionalCache();
16
		}
16
		}
17
		else {
17
		else {
18
			throw new IllegalArgumentException( "unrecognized access strategy type [" + accessType + "]" );
18
			throw new IllegalArgumentException( "unrecognized access strategy type [" + accessType + "]" );
19
		}
19
		}
20
		ccs.setCache( underlyingCache );
20
		ccs.setCache( underlyingCache );
21
		return new CollectionAccessStrategyAdapter( this, ccs, settings );
21
		return new EntityAccessStrategyAdapter( this, ccs, settings );
Summary
Number of common nesting structure subtrees1
Number of refactorable cases0
Number of non-refactorable cases1
Time elapsed for finding largest common nesting structure subtrees (ms)1.1
Clones locationClones are in different classes having the same super class
Number of node comparisons49
  1. {Non-refactorable}
    Mapping Summary
    Number of mapped statements13
    Number of unmapped statements in the first code fragment1
    Number of unmapped statements in the second code fragment1
    Time elapsed for statement mapping (ms)12.6
    Clone typeType 2
    Mapped Statements
    ID Statement ID Statement
    1
    CacheConcurrencyStrategy ccs;
    1
    CacheConcurrencyStrategy ccs;
    2
    if (AccessType.READ_ONLY.equals(accessType))
    2
    if (AccessType.READ_ONLY.equals(accessType))
    3
    if (metadata.isMutable())
    3
    if (metadata.isMutable())
    4
    log.warn("read-only cache configured for mutable collection [" + getName() + "]");
    4
    log.warn("read-only cache configured for mutable collection [" + getName() + "]");
    4
    log.warn("read-only cache configured for mutable entity [" + getName() + "]");
    Differences
    Expression1Expression2Difference
    "read-only cache configured for mutable collection [""read-only cache configured for mutable entity ["LITERAL_VALUE_MISMATCH
    4
    log.warn("read-only cache configured for mutable entity [" + getName() + "]");
    5
    ccs = new ReadOnlyCache();
    5
    ccs = new ReadOnlyCache();
    6
    else if (AccessType.READ_WRITE.equals(accessType))
    6
    else if (AccessType.READ_WRITE.equals(accessType))
    7
    ccs = new ReadWriteCache();
    7
    ccs = new ReadWriteCache();
    8
    else if (AccessType.NONSTRICT_READ_WRITE.equals(accessType))
    8
    else if (AccessType.NONSTRICT_READ_WRITE.equals(accessType))
    9
    ccs = new NonstrictReadWriteCache();
    9
    ccs = new NonstrictReadWriteCache();
    10
    else if (AccessType.TRANSACTIONAL.equals(accessType))
    10
    else if (AccessType.TRANSACTIONAL.equals(accessType))
    11
    ccs = new TransactionalCache();
    11
    ccs = new TransactionalCache();
    else
    else
    12
    throw new IllegalArgumentException("unrecognized access strategy type [" + accessType + "]");
    12
    throw new IllegalArgumentException("unrecognized access strategy type [" + accessType + "]");
    13
    ccs.setCache(underlyingCache);
    13
    ccs.setCache(underlyingCache);
                                                                                                                                
    14
    return new EntityAccessStrategyAdapter(this, ccs, settings);
    Preondition Violations
    Unmatched statement return new EntityAccessStrategyAdapter(this,ccs,settings); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return new EntityAccessStrategyAdapter(this,ccs,settings);
    14
    return new EntityAccessStrategyAdapter(this, ccs, settings);
    14
    return new CollectionAccessStrategyAdapter(this, ccs, settings);
    14
    return new CollectionAccessStrategyAdapter(this, ccs, settings);
    Preondition Violations
    Unmatched statement return new CollectionAccessStrategyAdapter(this,ccs,settings); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    Unmatched return new CollectionAccessStrategyAdapter(this,ccs,settings);
                                                                                                                                        
    Precondition Violations (4)
    Row Violation
    1Unmatched statement return new EntityAccessStrategyAdapter(this,ccs,settings); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    2Unmatched return new EntityAccessStrategyAdapter(this,ccs,settings);
    3Unmatched statement return new CollectionAccessStrategyAdapter(this,ccs,settings); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted
    4Unmatched return new CollectionAccessStrategyAdapter(this,ccs,settings);