com.netflix.hollow.api.objects.generic.GenericHollowSet Maven / Gradle / Ivy
/*
* Copyright 2016-2019 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.netflix.hollow.api.objects.generic;
import com.netflix.hollow.api.objects.HollowRecord;
import com.netflix.hollow.api.objects.HollowSet;
import com.netflix.hollow.api.objects.delegate.HollowSetDelegate;
import com.netflix.hollow.api.objects.delegate.HollowSetLookupDelegate;
import com.netflix.hollow.core.read.dataaccess.HollowDataAccess;
import com.netflix.hollow.core.read.dataaccess.HollowSetTypeDataAccess;
import com.netflix.hollow.tools.stringifier.HollowRecordStringifier;
/**
* This is a generic handle to a SET type record.
*
* The Generic Hollow Object API can be used to programmatically inspect a dataset (referenced by a {@link HollowDataAccess})
* without a custom-generated API.
*/
public class GenericHollowSet extends HollowSet {
public GenericHollowSet(HollowDataAccess dataAccess, String type, int ordinal) {
this((HollowSetTypeDataAccess)dataAccess.getTypeDataAccess(type, ordinal), ordinal);
}
public GenericHollowSet(HollowSetTypeDataAccess dataAccess, int ordinal) {
this(new HollowSetLookupDelegate(dataAccess), ordinal);
}
public GenericHollowSet(HollowSetDelegate delegate, int ordinal) {
super(delegate, ordinal);
}
public Iterable objects() {
return new GenericHollowIterable(this);
}
public Iterable lists() {
return new GenericHollowIterable(this);
}
public Iterable sets() {
return new GenericHollowIterable(this);
}
public Iterable maps() {
return new GenericHollowIterable(this);
}
@Override
public HollowRecord instantiateElement(int elementOrdinal) {
return GenericHollowRecordHelper.instantiate(getTypeDataAccess().getDataAccess(), getSchema().getElementType(), elementOrdinal);
}
@Override
public boolean equalsElement(int elementOrdinal, Object testObject) {
return GenericHollowRecordHelper.equalObject(getSchema().getElementType(), elementOrdinal, testObject);
}
@Override
public String toString() {
return new HollowRecordStringifier().stringify(this);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy