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.progmodel.facets.object.membergroups; 021 022import java.util.Arrays; 023import java.util.List; 024 025import org.apache.isis.applib.annotation.MemberGroupLayout.ColumnSpans; 026import org.apache.isis.core.metamodel.facetapi.Facet; 027import org.apache.isis.core.metamodel.facetapi.FacetAbstract; 028import org.apache.isis.core.metamodel.facetapi.FacetHolder; 029import org.apache.isis.core.metamodel.facets.object.membergroups.MemberGroupLayoutFacet; 030 031public abstract class MemberGroupLayoutFacetAbstract extends FacetAbstract implements MemberGroupLayoutFacet { 032 033 private final ColumnSpans columns; 034 private final List<String> left; 035 private final List<String> middle; 036 private final List<String> right; 037 038 public static Class<? extends Facet> type() { 039 return MemberGroupLayoutFacet.class; 040 } 041 042 protected static List<String> asListWithDefaultGroup(final String[] value) { 043 return value == null || value.length == 0 044 ? Arrays.asList(MemberGroupLayoutFacet.DEFAULT_GROUP) 045 : Arrays.asList(value); 046 } 047 048 protected static List<String> asList(final String[] value) { 049 return Arrays.asList(value); 050 } 051 052 public MemberGroupLayoutFacetAbstract( 053 final ColumnSpans columns, 054 final List<String> left, final List<String> middle, final List<String> right, 055 FacetHolder holder) { 056 super(type(), holder, Derivation.NOT_DERIVED); 057 this.columns = columns != null? columns: ColumnSpans.asSpans(4,0,0,8); 058 this.left = left; 059 this.middle = middle; 060 this.right = right; 061 } 062 063 @Override 064 public ColumnSpans getColumnSpans() { 065 return columns; 066 } 067 068 @Override 069 public List<String> getLeft() { 070 return left; 071 } 072 073 @Override 074 public List<String> getMiddle() { 075 return middle; 076 } 077 078 @Override 079 public List<String> getRight() { 080 return right; 081 } 082}