001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019 020package org.apache.isis.core.metamodel.adapter.oid; 021 022import org.apache.isis.core.commons.ensure.Assert; 023import org.apache.isis.core.metamodel.adapter.version.Version; 024 025 026/** 027 * Base type of the {@link Oid} for collections and for <tt>@Aggregated</tt> 028 * types. 029 * 030 * @see AggregatedOid 031 * @see CollectionOid 032 */ 033public abstract class ParentedOid implements Oid { 034 035 private final TypedOid parentOid; 036 037 public ParentedOid(TypedOid parentOid) { 038 Assert.assertNotNull("parentOid required", parentOid); 039 this.parentOid = parentOid; 040 } 041 042 public TypedOid getParentOid() { 043 return parentOid; 044 } 045 046 @Override 047 public Version getVersion() { 048 return parentOid.getVersion(); 049 } 050 051 @Override 052 public void setVersion(Version version) { 053 parentOid.setVersion(version); 054 } 055 056 057 @Override 058 public boolean isTransient() { 059 return getParentOid().isTransient(); 060 } 061 062 @Override 063 public boolean isViewModel() { 064 return getParentOid().isViewModel(); 065 } 066 067 @Override 068 public boolean isPersistent() { 069 return getParentOid().isPersistent(); 070 } 071 072 073 // ///////////////////////////////////////////////////////// 074 // toString 075 // ///////////////////////////////////////////////////////// 076 077 @Override 078 public String toString() { 079 return enString(new OidMarshaller()); 080 } 081 082 083}