All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ceylon.language.serialization.ReferencesImpl.ceylon Maven / Gradle / Ivy

There is a newer version: 1.3.3
Show newest version
import ceylon.language.impl{
    BaseIterator, 
    BaseIterable,
    reach
}

class ReferencesImpl(instance) extends BaseIterableAnything, Null>() 
        satisfies References&Identifiable {
    shared actual Anything instance;
    
    shared actual IteratorAnything> iterator() {
        if (exists instance) {
            return object extends BaseIteratorAnything>() 
                    satisfies Identifiable {
                Iterator it = outer.references.iterator();
                
                shared actual Anything>|Finished next() {
                    ReachableReference|Finished next = it.next();
                    if (is Finished next) {
                        return finished;
                    } else {
                        return next->next.referred(instance);
                    }
                }
            };
        } else {
            return emptyIterator;
        }
    }
    
    shared actual Iterable*/> references {
        return object extends BaseIterable() 
                satisfies Identifiable {
            shared actual Iterator iterator() {
                return reach.references(instance);
            }
        };
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy