001/*
002 * Copyright 2015-2020 the original author or authors
003 *
004 * This software is licensed under the Apache License, Version 2.0,
005 * the GNU Lesser General Public License version 2 or later ("LGPL")
006 * and the WTFPL.
007 * You may choose either license to govern your use of this software only
008 * upon the condition that you accept all of the terms of either
009 * the Apache License 2.0, the LGPL 2.1+ or the WTFPL.
010 */
011package org.minidns.record;
012
013import java.io.DataOutputStream;
014import java.io.IOException;
015
016import org.minidns.dnsname.DnsName;
017
018/**
019 * A resource record pointing to a target.
020 */
021public abstract class RRWithTarget extends Data {
022
023    public final DnsName target;
024
025    /**
026     * The target of this resource record.
027     * @deprecated {@link #target} instead.
028     */
029    @Deprecated
030    public final DnsName name;
031
032    @Override
033    public void serialize(DataOutputStream dos) throws IOException {
034        target.writeToStream(dos);
035    }
036
037    protected RRWithTarget(DnsName target) {
038        this.target = target;
039        this.name = target;
040    }
041
042    @Override
043    public String toString() {
044        return target + ".";
045    }
046
047    public final DnsName getTarget() {
048        return target;
049    }
050}