
dev.ikm.tinkar.entity.SemanticRecord Maven / Gradle / Ivy
/*
* Copyright © 2015 Integrated Knowledge Management ([email protected])
*
* 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 dev.ikm.tinkar.entity;
import dev.ikm.tinkar.common.id.PublicId;
import dev.ikm.tinkar.common.service.PrimitiveData;
import dev.ikm.tinkar.common.util.Validator;
import dev.ikm.tinkar.terms.PatternFacade;
import io.soabase.recordbuilder.core.RecordBuilder;
import org.eclipse.collections.api.list.ImmutableList;
import java.util.Arrays;
import java.util.Objects;
import java.util.UUID;
@RecordBuilder
public record SemanticRecord(
long mostSignificantBits, long leastSignificantBits,
long[] additionalUuidLongs, int nid, int patternNid, int referencedComponentNid,
ImmutableList versions)
implements SemanticEntity, SemanticRecordBuilder.With {
public SemanticRecord {
Validator.notZero(mostSignificantBits);
Validator.notZero(leastSignificantBits);
Validator.notZero(nid);
Validator.notZero(patternNid);
Validator.notZero(referencedComponentNid);
Objects.requireNonNull(versions);
}
public static SemanticRecord makeNew(PublicId publicId, PatternFacade patternFacade, int referencedComponentNid,
RecordListBuilder versionListBuilder) {
return makeNew(publicId, patternFacade.nid(), referencedComponentNid, versionListBuilder);
}
public static SemanticRecord makeNew(PublicId publicId, int patternNid, int referencedComponentNid,
RecordListBuilder versionListBuilder) {
PublicIdentifierRecord publicIdRecord = PublicIdentifierRecord.make(publicId);
int nid = PrimitiveData.nid(publicId);
return new SemanticRecord(publicIdRecord.mostSignificantBits(), publicIdRecord.leastSignificantBits(),
publicIdRecord.additionalUuidLongs(), nid, patternNid, referencedComponentNid,
versionListBuilder);
}
public static SemanticRecord build(UUID semanticUuid,
int patternNid,
int referencedComponentNid,
StampEntityVersion stampVersion,
ImmutableList
© 2015 - 2025 Weber Informatics LLC | Privacy Policy