class PacketHeaderConstraintsUtil {

  public static AclLineMatchExpr toAclLineMatchExpr(
      PacketHeaderConstraints phc, IpSpace srcIpSpace, IpSpace dstIpSpace) {
    List<AclLineMatchExpr> conjuncts =
        Stream.of(
                matchSrc(srcIpSpace),
                matchDst(dstIpSpace),
                dscpsToAclLineMatchExpr(phc.getDscps()),
                ecnsToAclLineMatchExpr(phc.getEcns()),
                packetLengthToAclLineMatchExpr(phc.getPacketLengths()),
                fragmentOffsetsToAclLineMatchExpr(phc.getFragmentOffsets()),
                ipProtocolsToAclLineMatchExpr(phc.getIpProtocols()),
                icmpCodeToAclLineMatchExpr(phc.getIcmpCodes()),
                icmpTypeToAclLineMatchExpr(phc.getIcmpTypes()),
                srcPortsToAclLineMatchExpr(phc.getSrcPorts()),
                dstPortsToAclLineMatchExpr(phc.getDstPorts()),
                applicationsToAclLineMatchExpr(phc.getApplications()),
                tcpFlagsToAclLineMatchExpr(phc.getTcpFlags()))
            .filter(Objects::nonNull)
            .collect(ImmutableList.toImmutableList());

    return and(conjuncts);
  }

}