2016-01-27 22:20:42 +00:00
|
|
|
/**
|
|
|
|
* The MIT License
|
2016-11-27 14:34:20 +02:00
|
|
|
* Copyright (c) 2014-2016 Ilkka Seppälä
|
2016-01-27 22:20:42 +00:00
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
2015-05-31 11:55:18 +03:00
|
|
|
package com.iluwatar.privateclassdata;
|
2015-05-23 15:52:50 +03:00
|
|
|
|
2016-10-23 19:59:03 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2015-05-23 16:07:04 +03:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* Immutable stew class, protected with Private Class Data pattern
|
|
|
|
*
|
|
|
|
*/
|
2015-05-23 15:52:50 +03:00
|
|
|
public class ImmutableStew {
|
|
|
|
|
2016-10-23 19:59:03 +02:00
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(ImmutableStew.class);
|
|
|
|
|
2015-11-01 21:29:13 -05:00
|
|
|
private StewData data;
|
|
|
|
|
|
|
|
public ImmutableStew(int numPotatoes, int numCarrots, int numMeat, int numPeppers) {
|
|
|
|
data = new StewData(numPotatoes, numCarrots, numMeat, numPeppers);
|
|
|
|
}
|
|
|
|
|
2015-12-25 23:49:28 +02:00
|
|
|
/**
|
|
|
|
* Mix the stew
|
|
|
|
*/
|
2015-11-01 21:29:13 -05:00
|
|
|
public void mix() {
|
2016-10-23 19:59:03 +02:00
|
|
|
LOGGER.info("Mixing the immutable stew we find: {} potatoes, {} carrots, {} meat and {} peppers",
|
|
|
|
data.getNumPotatoes(), data.getNumCarrots(), data.getNumMeat(), data.getNumPeppers());
|
2015-11-01 21:29:13 -05:00
|
|
|
}
|
2015-05-23 15:52:50 +03:00
|
|
|
}
|