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

org.jsimpledb.demo.AbstractHasSatellites Maven / Gradle / Ivy

There is a newer version: 3.6.1
Show newest version

/*
 * Copyright (C) 2015 Archie L. Cobbs. All rights reserved.
 */

package org.jsimpledb.demo;

import java.util.NavigableSet;

import org.jsimpledb.JObject;
import org.jsimpledb.util.NavigableSets;

/**
 * Support superclass for {@link HasSatellites} implementations.
 */
public abstract class AbstractHasSatellites> extends AbstractBody implements HasSatellites {

    private final Class satelliteType;

    protected AbstractHasSatellites(Class satelliteType) {
        this.satelliteType = satelliteType;
    }

    @Override
    public NavigableSet getSatellites() {
        final NavigableSet satellites = this.getTransaction().queryIndex(
          this.satelliteType, "parent", JObject.class).asMap().get(this);
        return satellites != null ? satellites : NavigableSets.empty();
    }
}