blob: 1da00cf58f9f2c796131c5baf69c1c51f3f0954f [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>AccountTransaction.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Shiro :: Samples :: AspectJ</a> &gt; <a href="index.source.html" class="el_package">org.apache.shiro.samples.aspectj.bank</a> &gt; <span class="el_source">AccountTransaction.java</span></div><h1>AccountTransaction.java</h1><pre class="source lang-java linenums"><span class="nc" id="L1">/*</span>
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* &quot;License&quot;); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.shiro.samples.aspectj.bank;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import java.sql.Timestamp;
import java.util.Date;
public class AccountTransaction {
private static long _SEQUENCE;
<span class="fc" id="L31"> public enum TransactionType {</span>
<span class="fc" id="L32"> DEPOSIT,</span>
<span class="fc" id="L33"> WITHDRAWAL</span>
}
private long _id;
private TransactionType _type;
private long _accountId;
private double _amount;
private String _createdBy;
private Date _creationDate;
public static AccountTransaction createDepositTx(long anAccountId, double anAmount) {
<span class="fc" id="L48"> return new AccountTransaction(TransactionType.DEPOSIT, anAccountId, anAmount);</span>
}
public static AccountTransaction createWithdrawalTx(long anAccountId, double anAmount) {
<span class="fc" id="L52"> return new AccountTransaction(TransactionType.WITHDRAWAL, anAccountId, anAmount);</span>
}
<span class="fc" id="L55"> private AccountTransaction(TransactionType aType, long anAccountId, double anAmount) {</span>
<span class="fc" id="L56"> _id = ++_SEQUENCE;</span>
<span class="fc" id="L57"> _type = aType;</span>
<span class="fc" id="L58"> _accountId = anAccountId;</span>
<span class="fc" id="L59"> _amount = anAmount;</span>
<span class="fc" id="L60"> _createdBy = &quot;unknown&quot;;</span>
<span class="fc" id="L61"> _creationDate = new Date();</span>
<span class="fc" id="L62"> }</span>
/**
* Returns the id attribute.
*
* @return The id value.
*/
public long getId() {
<span class="nc" id="L70"> return _id;</span>
}
/**
* Returns the type attribute.
*
* @return The type value.
*/
public TransactionType getType() {
<span class="fc" id="L79"> return _type;</span>
}
/**
* Returns the accountId attribute.
*
* @return The accountId value.
*/
public long getAccountId() {
<span class="nc" id="L88"> return _accountId;</span>
}
/**
* Returns the amount attribute.
*
* @return The amount value.
*/
public double getAmount() {
<span class="fc" id="L97"> return _amount;</span>
}
/**
* Changes the value of the attributes createdBy.
*
* @param aCreatedBy The new value of the createdBy attribute.
*/
protected void setCreatedBy(String aCreatedBy) {
<span class="fc" id="L106"> _createdBy = aCreatedBy;</span>
<span class="fc" id="L107"> }</span>
/**
* Returns the createdBy attribute.
*
* @return The createdBy value.
*/
public String getCreatedBy() {
<span class="fc" id="L115"> return _createdBy;</span>
}
/**
* Returns the creationDate attribute.
*
* @return The creationDate value.
*/
public Date getCreationDate() {
<span class="fc" id="L124"> return _creationDate;</span>
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
public String toString() {
<span class="fc" id="L132"> return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).</span>
<span class="fc" id="L133"> append(&quot;id&quot;, _id).</span>
<span class="fc" id="L134"> append(&quot;type&quot;, _type).</span>
<span class="fc" id="L135"> append(&quot;accountId&quot;, _accountId).</span>
<span class="fc" id="L136"> append(&quot;amount&quot;, _amount).</span>
<span class="fc" id="L137"> append(&quot;createdBy&quot;, _createdBy).</span>
<span class="fc" id="L138"> append(&quot;creationDate&quot;, new Timestamp(_creationDate.getTime())).</span>
<span class="fc" id="L139"> toString();</span>
}
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.eclemma.org/jacoco">JaCoCo</a> 0.7.7.201606060606</span></div></body></html>