@Test public void intern(){ ScoreDistribution left = new ScoreDistribution("event", 0.33d); ScoreDistribution right = new ScoreDistribution("event", 0.33d); Node leftChild = createNode(left); Node rightChild = createNode(right); Node root = new ComplexNode(True.INSTANCE) .addNodes(leftChild, rightChild); TreeModel treeModel = new TreeModel() .setNode(root); for(int i = 0; i < 2; i++){ assertNotSame((leftChild.getScoreDistributions()).get(i), (rightChild.getScoreDistributions()).get(i)); } ScoreDistributionInterner interner = new ScoreDistributionInterner(); interner.applyTo(treeModel); for(int i = 0; i < 2; i++){ assertSame((leftChild.getScoreDistributions()).get(i), (rightChild.getScoreDistributions()).get(i)); } }
private ScoreDistribution intern(ScoreDistribution scoreDistribution){ if(scoreDistribution == null || scoreDistribution.hasExtensions()){ return scoreDistribution; } return this.cache.intern(scoreDistribution); }
ScoreDistributionInterner extends AbstractVisitor { private ScoreDistribution intern(ScoreDistribution scoreDistribution){ if(scoreDistribution == null || scoreDistribution.hasExtensions()){ return scoreDistribution; } return this.cache.intern(scoreDistribution); } }
ScoreDistributionInterner extends AbstractVisitor { private ScoreDistribution intern(ScoreDistribution scoreDistribution){ if(scoreDistribution == null || scoreDistribution.hasExtensions()){ return scoreDistribution; } return this.cache.intern(scoreDistribution); }  }
ScoreDistributionInterner extends AbstractVisitor { private ScoreDistribution intern(ScoreDistribution scoreDistribution){ if(scoreDistribution == null || scoreDistribution.hasExtensions()){ return scoreDistribution; } return this.cache.intern(scoreDistribution); }  @Override VisitorAction visit(Node node); }
ScoreDistributionInterner extends AbstractVisitor { private ScoreDistribution intern(ScoreDistribution scoreDistribution){ if(scoreDistribution == null || scoreDistribution.hasExtensions()){ return scoreDistribution; } return this.cache.intern(scoreDistribution); }  @Override VisitorAction visit(Node node);  }