Bi-directional Associations

Consider the following requirement:

A fulfilment system allows sales people to locate a customer from the customer's account and vice-versa.

This suggests a bi-directional association between customer and account:

Notice that a bi-directional association is different from two uni-directional associations pointing in opposite directions:

In the Account-Customer association if customer C is linked to account A, then A must be linked to C. On the other hand, factory F may use product P, but this does not mean that P was made by F.

Implementing a bi-directional association is tricky because we want to insure that if customer C is linked to account A, then A links back to C and not some different customer. To insure this, one side of a bi-directional association has to be designated as the manager of the association. Often times this decision is arbitrary. If, for example, Customer manages the association to Account, then the Customer constructor should insure create the customer's account and set the account's customer link back to itself:

TestCustomer.java

Notice that it's not possible to change the customer of an account.

Problem

Of course it's still possible to construct an account having a customer with a different account. For example:

Customer smith = new Customer("Smith");
Account acct1 = new Account(smith); // smith.getAccount() != acct1

In C++ this could be overcome by making the Account class constructor private and declaring the Customer class to be a friend of the Account class. But how could this be done in Java?