📄 simpletracegenerator.java
字号:
/*j8583 A Java implementation of the ISO8583 protocolCopyright (C) 2007 Enrique Zamudio LopezThis library is free software; you can redistribute it and/ormodify it under the terms of the GNU Lesser General PublicLicense as published by the Free Software Foundation; eitherversion 2.1 of the License, or (at your option) any later version.This library is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNULesser General Public License for more details.You should have received a copy of the GNU Lesser General PublicLicense along with this library; if not, write to the Free SoftwareFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA*/package com.solab.iso8583.impl;import com.solab.iso8583.TraceNumberGenerator;/** Simple implementation of a TraceNumberGenerator with an internal * number that is increased in memory but is not stored anywhere. * * @author Enrique Zamudio */public class SimpleTraceGenerator implements TraceNumberGenerator { private int value = 0; /** Creates a new instance that will use the specified initial value. This means * the first nextTrace() call will return this number. * @param initialValue a number between 1 and 999999. * @throws IllegalArgumentException if the number is less than 1 or greater than 999999. */ public SimpleTraceGenerator(int initialValue) { if (initialValue < 1 || initialValue > 999999) { throw new IllegalArgumentException("Initial value must be between 1 and 999999"); } value = initialValue - 1; } public int getLastTrace() { return value; } /** Returns the next number in the sequence. This method is synchronized, because the counter * is incremented in memory only. */ public synchronized int nextTrace() { value++; if (value > 999999) { value = 1; } return value; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -