View Javadoc
1   package org.kuali.common.aws.s3.model;
2   
3   import javax.validation.constraints.Min;
4   
5   import org.kuali.common.core.build.ValidatingBuilder;
6   import org.kuali.common.core.validate.annotation.IdiotProofImmutable;
7   
8   @IdiotProofImmutable
9   public final class Bucket {
10  
11  	private final String name;
12  	private final Owner owner;
13  	@Min(0)
14  	private final long created;
15  
16  	private Bucket(Builder builder) {
17  		this.name = builder.name;
18  		this.owner = builder.owner;
19  		this.created = builder.created;
20  	}
21  
22  	public static Bucket copyOf(com.amazonaws.services.s3.model.Bucket bucket) {
23  		String name = bucket.getName();
24  		Owner owner = Owner.copyOf(bucket.getOwner());
25  		long timestamp = bucket.getCreationDate().getTime();
26  		return builder().withName(name).withOwner(owner).withCreated(timestamp).build();
27  	}
28  
29  	public static Builder builder() {
30  		return new Builder();
31  	}
32  
33  	public static class Builder extends ValidatingBuilder<Bucket> {
34  
35  		private String name;
36  		private Owner owner;
37  		private long created;
38  
39  		public Builder withName(String name) {
40  			this.name = name;
41  			return this;
42  		}
43  
44  		public Builder withOwner(Owner owner) {
45  			this.owner = owner;
46  			return this;
47  		}
48  
49  		public Builder withCreated(long created) {
50  			this.created = created;
51  			return this;
52  		}
53  
54  		@Override
55  		public Bucket build() {
56  			return validate(new Bucket(this));
57  		}
58  	}
59  
60  	public String getName() {
61  		return name;
62  	}
63  
64  	public Owner getOwner() {
65  		return owner;
66  	}
67  
68  	public long getCreated() {
69  		return created;
70  	}
71  
72  }