Coverage Report - com.sun.javafx.runtime.sequence.BoundSingletonSequence
 
Classes in this File Line Coverage Branch Coverage Complexity
BoundSingletonSequence
100%
8/8
N/A
0
BoundSingletonSequence$1
100%
3/3
N/A
0
 
 1  
 package com.sun.javafx.runtime.sequence;
 2  
 
 3  
 import com.sun.javafx.runtime.location.ObjectChangeListener;
 4  
 import com.sun.javafx.runtime.location.ObjectLocation;
 5  
 import com.sun.javafx.runtime.location.SequenceLocation;
 6  
 
 7  
 /**
 8  
  * BoundSingletonSequence
 9  
  *
 10  
  * @author Brian Goetz
 11  
  */
 12  
 class BoundSingletonSequence<T, V extends T> extends AbstractBoundSequence<T> implements SequenceLocation<T> {
 13  
     private final ObjectLocation<V> location;
 14  
 
 15  
     public BoundSingletonSequence(Class<T> clazz, ObjectLocation<V> location) {
 16  665
         super(clazz);
 17  665
         this.location = location;
 18  665
         setInitialValue(computeValue());
 19  665
         addTriggers();
 20  665
     }
 21  
 
 22  
     private Sequence<T> computeValue() {
 23  665
         return Sequences.singleton(getClazz(), location.get());
 24  
     }
 25  
 
 26  
     private void addTriggers() {
 27  665
         location.addChangeListener(new ObjectChangeListener<V>() {
 28  
             public void onChange(V oldValue, V newValue) {
 29  35
                 updateSlice(0, getRawValue().size() - 1, Sequences.singleton(getClazz(), newValue));
 30  35
             }
 31  
         });
 32  665
     }
 33  
 }