// 
// Decompiled by Procyon v0.6.0
// 

package org.bouncycastle.oer.its.ieee1609dot2.basetypes;

import org.bouncycastle.util.BigIntegers;
import java.math.BigInteger;
import org.bouncycastle.asn1.DEROctetString;
import org.bouncycastle.asn1.DERSequence;
import org.bouncycastle.asn1.ASN1Encodable;
import org.bouncycastle.asn1.ASN1Primitive;
import org.bouncycastle.asn1.ASN1Sequence;
import org.bouncycastle.asn1.ASN1OctetString;
import org.bouncycastle.asn1.ASN1Object;

public class Point384 extends ASN1Object
{
    private final ASN1OctetString x;
    private final ASN1OctetString y;
    
    public Point384(final ASN1OctetString x, final ASN1OctetString y) {
        if (x.getOctets().length != 48) {
            throw new IllegalArgumentException("x must be 48 bytes long");
        }
        if (y.getOctets().length != 48) {
            throw new IllegalArgumentException("y must be 48 bytes long");
        }
        this.x = x;
        this.y = y;
    }
    
    private Point384(final ASN1Sequence asn1Sequence) {
        if (asn1Sequence.size() != 2) {
            throw new IllegalArgumentException("expected sequence size of 2");
        }
        this.x = ASN1OctetString.getInstance(asn1Sequence.getObjectAt(0));
        this.y = ASN1OctetString.getInstance(asn1Sequence.getObjectAt(1));
        if (this.x.getOctets().length != 48) {
            throw new IllegalArgumentException("x must be 48 bytes long");
        }
        if (this.y.getOctets().length != 48) {
            throw new IllegalArgumentException("y must be 48 bytes long");
        }
    }
    
    public static Point384 getInstance(final Object o) {
        if (o instanceof Point384) {
            return (Point384)o;
        }
        if (o != null) {
            return new Point384(ASN1Sequence.getInstance(o));
        }
        return null;
    }
    
    public ASN1OctetString getX() {
        return this.x;
    }
    
    public ASN1OctetString getY() {
        return this.y;
    }
    
    @Override
    public ASN1Primitive toASN1Primitive() {
        return new DERSequence(new ASN1Encodable[] { this.x, this.y });
    }
    
    public static Builder builder() {
        return new Builder();
    }
    
    public static class Builder
    {
        private ASN1OctetString x;
        private ASN1OctetString y;
        
        public Builder setX(final ASN1OctetString x) {
            this.x = x;
            return this;
        }
        
        public Builder setX(final byte[] array) {
            this.x = new DEROctetString(array);
            return this;
        }
        
        public Builder setX(final BigInteger bigInteger) {
            this.x = new DEROctetString(BigIntegers.asUnsignedByteArray(48, bigInteger));
            return this;
        }
        
        public Builder setY(final ASN1OctetString y) {
            this.y = y;
            return this;
        }
        
        public Builder setY(final byte[] array) {
            this.y = new DEROctetString(array);
            return this;
        }
        
        public Builder setY(final BigInteger bigInteger) {
            this.y = new DEROctetString(BigIntegers.asUnsignedByteArray(48, bigInteger));
            return this;
        }
        
        public Point384 createPoint384() {
            return new Point384(this.x, this.y);
        }
    }
}
