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.commons.lang3.tuple; 018 019/** 020 * <p>A mutable triple consisting of three {@code Object} elements.</p> 021 * 022 * <p>Not #ThreadSafe#</p> 023 * 024 * @param <L> the left element type 025 * @param <M> the middle element type 026 * @param <R> the right element type 027 * 028 * @version $Id: MutableTriple.java 1552635 2013-12-20 13:02:03Z britter $ 029 * @since 3.2 030 */ 031public class MutableTriple<L, M, R> extends Triple<L, M, R> { 032 033 /** Serialization version */ 034 private static final long serialVersionUID = 1L; 035 036 /** Left object */ 037 public L left; 038 /** Middle object */ 039 public M middle; 040 /** Right object */ 041 public R right; 042 043 /** 044 * <p>Obtains an mutable triple of three objects inferring the generic types.</p> 045 * 046 * <p>This factory allows the triple to be created using inference to 047 * obtain the generic types.</p> 048 * 049 * @param <L> the left element type 050 * @param <M> the middle element type 051 * @param <R> the right element type 052 * @param left the left element, may be null 053 * @param middle the middle element, may be null 054 * @param right the right element, may be null 055 * @return a triple formed from the three parameters, not null 056 */ 057 public static <L, M, R> MutableTriple<L, M, R> of(final L left, final M middle, final R right) { 058 return new MutableTriple<L, M, R>(left, middle, right); 059 } 060 061 /** 062 * Create a new triple instance of three nulls. 063 */ 064 public MutableTriple() { 065 super(); 066 } 067 068 /** 069 * Create a new triple instance. 070 * 071 * @param left the left value, may be null 072 * @param middle the middle value, may be null 073 * @param right the right value, may be null 074 */ 075 public MutableTriple(final L left, final M middle, final R right) { 076 super(); 077 this.left = left; 078 this.middle = middle; 079 this.right = right; 080 } 081 082 //----------------------------------------------------------------------- 083 /** 084 * {@inheritDoc} 085 */ 086 @Override 087 public L getLeft() { 088 return left; 089 } 090 091 /** 092 * Sets the left element of the triple. 093 * 094 * @param left the new value of the left element, may be null 095 */ 096 public void setLeft(final L left) { 097 this.left = left; 098 } 099 100 /** 101 * {@inheritDoc} 102 */ 103 @Override 104 public M getMiddle() { 105 return middle; 106 } 107 108 /** 109 * Sets the middle element of the triple. 110 * 111 * @param middle the new value of the middle element, may be null 112 */ 113 public void setMiddle(final M middle) { 114 this.middle = middle; 115 } 116 117 /** 118 * {@inheritDoc} 119 */ 120 @Override 121 public R getRight() { 122 return right; 123 } 124 125 /** 126 * Sets the right element of the triple. 127 * 128 * @param right the new value of the right element, may be null 129 */ 130 public void setRight(final R right) { 131 this.right = right; 132 } 133} 134