1 32 33 package com.jeantessier.diff; 34 35 39 public abstract class DecoratorDifferences implements Differences { 40 private Differences component; 41 42 45 DecoratorDifferences(Differences component) { 46 this.component = component; 47 } 48 49 public Differences getComponent() { 50 return component; 51 } 52 53 public Differences getLeafComponent() { 54 Differences result = null; 55 56 if (getComponent() instanceof DecoratorDifferences) { 57 result = ((DecoratorDifferences) getComponent()).getLeafComponent(); 58 } else { 59 result = getComponent(); 60 } 61 62 return result; 63 } 64 65 public String getName() { 66 return getComponent().getName(); 67 } 68 69 public String toString() { 70 return getComponent().toString(); 71 } 72 } 73 | Popular Tags |