001/** 002 * Copyright 2005-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.kuali.ole; 017 018/** 019 * Kuali Rice ArcheType Help 020 * <p/> 021 * This is an example of a service implementation. 022 * <p/> 023 * An implementation of the ProductService that uses addition. 024 */ 025public class AdditionProductServiceImpl implements ProductService { 026 @Override 027 public Integer product(Integer left, Integer right) { 028 029 if (left == null) { 030 throw new IllegalArgumentException("left is null"); 031 } 032 033 if (right == null) { 034 throw new IllegalArgumentException("right is null"); 035 } 036 037 final int absRight = Math.abs(right); 038 039 int sum = 0; 040 for (int i = 0; i < absRight; i++) { 041 sum += left; 042 } 043 044 return absRight != right.intValue() ? -sum : sum; 045 } 046}