001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.isis.core.metamodel.specloader.specimpl; 018 019import java.util.List; 020 021import org.apache.isis.core.commons.lang.ListExtensions; 022import org.apache.isis.core.metamodel.adapter.ObjectAdapter; 023import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter; 024 025public class OneToOneActionParameterContributee extends OneToOneActionParameterImpl implements ObjectActionParameterContributee{ 026 027 private final ObjectAdapter serviceAdapter; 028 @SuppressWarnings("unused") 029 private final ObjectActionImpl serviceAction; 030 private final ObjectActionParameter serviceActionParameter; 031 @SuppressWarnings("unused") 032 private final int serviceParamNumber; 033 @SuppressWarnings("unused") 034 private final int contributeeParamNumber; 035 private final ObjectActionContributee contributeeAction; 036 037 public OneToOneActionParameterContributee( 038 final ObjectAdapter serviceAdapter, 039 final ObjectActionImpl serviceAction, 040 final ObjectActionParameterAbstract serviceActionParameter, 041 final int serviceParamNumber, 042 final int contributeeParamNumber, 043 final ObjectActionContributee contributeeAction) { 044 super(contributeeParamNumber, contributeeAction, serviceActionParameter.getPeer()); 045 this.serviceAdapter = serviceAdapter; 046 this.serviceAction = serviceAction; 047 this.serviceActionParameter = serviceActionParameter; 048 this.serviceParamNumber = serviceParamNumber; 049 this.contributeeParamNumber = contributeeParamNumber; 050 this.contributeeAction = contributeeAction; 051 } 052 053 @Override 054 public ObjectAdapter[] getAutoComplete(ObjectAdapter adapter, String searchArg) { 055 return serviceActionParameter.getAutoComplete(serviceAdapter, searchArg); 056 } 057 058 protected ObjectAdapter targetForDefaultOrChoices(ObjectAdapter adapter, final List<ObjectAdapter> argumentsIfAvailable) { 059 return serviceAdapter; 060 } 061 062 protected List<ObjectAdapter> argsForDefaultOrChoices(final ObjectAdapter contributee, final List<ObjectAdapter> argumentsIfAvailable) { 063 064 final List<ObjectAdapter> suppliedArgs = ListExtensions.mutableCopy(argumentsIfAvailable); 065 066 final int contributeeParam = contributeeAction.getContributeeParam(); 067 ListExtensions.insert(suppliedArgs, contributeeParam, contributee); 068 069 return suppliedArgs; 070 } 071 072}